Question

In: Computer Science

Create a Class to contain a customer order Create attributes of that class to store Company...

Create a Class to contain a customer order

Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes.

Create a class constructor without parameters that initializes the attributes to default values.

Create a class constructor with parameters that initializes the attributes to the passed in parameter values.

Create a behavior of that class to generate a welcome message that includes the company name.

Create a Class to contain a customer order detail row

Create attributes of that class to store Product Name, Price and Amount. Create a public property for each of these attributes.

Create a constructor without parameters that set all the attributes to an empty string or zero.

Create a constructor with parameters that sets all the attributes to the passed in parameters.

Create a behavior that, when provided a sales tax value, returns the total price for a detail row including sales tax.

Create a behavior that, when provided a product name, price and quantity, returns a single line order detail.

Initialize a Customer order object instance.

For a custom order detail line, prompt the user to enter a product name, price and amount (each separately). Initialize a customer order detail object instance with the values provided.

Repeats this two more times for a total of three customer order details.

Using the behavior in Customer Order, display the header information in the console.

Using the behavior in Customer Order Detail, display the three order detail lines in the console (each on a separate line).

Pause the console for a final user input before.

Solutions

Expert Solution

Screenshot of the code:

Output:

Code to copy:

#include<iostream>

#include<string>

using namespace std;

//Define the class customer order

class customerOrder

{

//Define the public data members of the class.

public:

     string Company_Name, Address;

     double Sales_Tax;

     double tt = 0;

    

     //Define the default constuctor to set default values.

     customerOrder()

     {

          Company_Name = "\0";

          Address = "\0";

          Sales_Tax = 0;

     }

     //Define the parametrized constuctor to set the values.

     customerOrder(string const name, string const a, double t)

     {

          Company_Name = name;

          Address = a;

          Sales_Tax = t;

          tt = t;

          welcome();

     }

//Define the function to display the headings.

     void welcome()

     {

          cout << "\n\t<<< Welcome to the "

               << Company_Name << " >>>\n";

     }

};

//Define the orderDetailed class.

class orderDetail : public customerOrder

{

//Define the public data members of the class.

public:

     string product_Name[3];

     double pprice[3], pamount[3], t;

    

     //Define the default constuctor to set default values.

     orderDetail()

     {

          for (int i = 0; i<3; i++)

          {

              product_Name[i] = "\0";

              pprice[i] = 0;

              pamount[i] = 0;

          }

     }

     //Define the parametrized constuctor to set the values.

     orderDetail(string *p_name, double *pr, double *amount)

     {

          for (int i = 0; i<3; i++)

          {

              product_Name[i] = p_name[i];

              pprice[i] = pr[i];

              pamount[i] = amount[i];

          }

     }

    

     //Define the function to display the order details.

     void Sdisplay(int *q)

     {

          // Display the order record in a row.

          cout << "Simple order details :";

          cout << "\nOrder Number\t| product Name"

               <<"\t| quantity\t| price \n";

          for (int iter = 0; iter<3; iter++)

          {

              cout << iter + 1 << "\t\t|" << product_Name[iter]

                   << "\t\t|" << q[iter]

                   << "\t\t|" << pprice[iter] << "\n";

          }

          cout << "------------------------------------------\n";

     }

    

     //Define the function to calculate the price as

     //per the tax and quantity.

     void Caldisplay(int *q, double tax)

     {

          // Display the order record in a row.

          t = tax;

          double tprice = 0;

          cout << "Order detail with calculated "

               <<"price including the salestax:";

          cout << "\nOrder Number\t| product Name"

               <<"\t| quantity\t| price \n";

          for (int i = 0; i<3; i++)

          {

              double totalPrice = 0;

              totalPrice = pprice[i] + (t*pprice[i]) / 100;

              cout << i + 1 << "\t\t|" << product_Name[i]

                   << "\t\t|" << q[i]

                   << "\t\t|" << totalPrice*q[i] << "\n";

              tprice = tprice + totalPrice*q[i];

          }

          cout << "------------------------------------------\n";

          tprice = Calprice(q);

          cout << "Total calculated price :\t\t " << tprice

         << "\n";

     }

     //Define the function to calculate the price.

     double Calprice(int *q)

     {

          double tp = 0, e = 0;

          for (int i = 0; i<3; i++)

          {

              tp = (pprice[i] + (t*pprice[i]) / 100)*q[i];

              e = e + tp;

          }

          return e;

     }

};

int main()

{

//Define the variables.

     string cname, address, productname[3];

     double t, price[3], amount[3];

     int q[3];

   //Accept the input for customerOrder class.

     cout << "Enter the company name : ";

     getline(cin, cname);

     cout << "Enter the address : ";      

     getline(cin, address);

     cout << "Enter the sales tax:";       

     cin >> t;

   //Call the parametrized constuctor of the class

   //customerOrder.

     customerOrder coobj(cname, address, t);

    

     //Accept the input for customerOrder class.

     cout << "\n--- Provide the details for the order ---- \n";

     for (int iter = 0; iter<3; iter++)

     {

          cout << iter + 1 << ".Enter the product name:";     

          cin >> productname[iter];

          cout << " Enter the product price:";        

          cin >> price[iter];

          cout << " Enter the amount : ";    

          cin >> amount[iter];

          cout << " Enter the quantity : ";    

          cin >> q[iter];

     }

   //Call the parametrized constuctor of the class

   //customerOrder.

     orderDetail odobj(productname, price, amount);

    

     //Call the function of the class orderDetail.

     odobj.Sdisplay(q);

     odobj.Caldisplay(q, t);

}


Related Solutions

PYTHON- create a queue class that uses a LINKEDLIST in order to store data. this queue...
PYTHON- create a queue class that uses a LINKEDLIST in order to store data. this queue will call on a linkedlist class class Queue: def __init__(self): self.items = LinkedList() #has to be O(1) def enqueue(self, item): #has to be O(1) def dequeue(self): def is_empty(self): def __len__(self):
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name...
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize...
C# windows application form. Create a base class to store characteristics about a loan. Include customer...
C# windows application form. Create a base class to store characteristics about a loan. Include customer details in the Loan base class such as name, loan number, and amount of loan. Define subclasses of auto loan and home loan. Include unique characteristics in the derived classes. For example you might include details about the specific auto in the auto loan class and details about the home in the home loan class. Create a presentation class to test your design by...
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
In python- Create a class defined for Regression. Class attributes are data points for x, y,...
In python- Create a class defined for Regression. Class attributes are data points for x, y, the slope and the intercept for the regression line. Define an instance method to find the regression line parameters (slope and intercept). Plot all data points on the graph. Plot the regression line on the same plot.
Create a car class with three attributes: year, mpg, speed and list of owners. The class...
Create a car class with three attributes: year, mpg, speed and list of owners. The class also should have 2 methods called accelerate and brake. Whenever the car accelerates, its speed is increased by 30 and whenever the car brakes, its speed is reduced by 60. add a constructor to the class, which takes year, mpg, and speed as input implement a magic method that prints the car information including year, speed and mpg. That is, for a car object,...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain 3 double variables containing the length of each of the triangles three sides. Create a constructor with three parameters to initialize the three sides of the triangle. Add an additional method named checkSides with method header - *boolean checkSides() throws IllegalTriangleSideException *. Write code so that checkSides makes sure that the three sides of the triangle meet the proper criteria for a triangle. It...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain 3 double variables containing the length of each of the triangles three sides. Create a constructor with three parameters to initialize the three sides of the triangle. Add an additional method named checkSides with method header - *boolean checkSides() throws IllegalTriangleSideException *. Write code so that checkSides makes sure that the three sides of the triangle meet the proper criteria for a triangle. It...
(Rectangle Class) Create class Rectangle. The class has attributes length and width, each of which defaults...
(Rectangle Class) Create class Rectangle. The class has attributes length and width, each of which defaults to 1. It has read-only properties that calculate the Perimeter and the Area of the rectangle. It has properties for both length and width. The set accessors should verify that length and width are each floating-point numbers greater than 0.0 and less than 20.0. Write an app to test class Rectangle. this is c sharp program please type the whole program.
Write a class Store which includes the attributes: store name and sales tax rate. Write another...
Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a method returning the average taxes per year....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT