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

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 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.
Create java Class with name Conversion. Instructions for Conversion class: The Conversion class will contain methods...
Create java Class with name Conversion. Instructions for Conversion class: The Conversion class will contain methods designed to perform simple conversions. Specifically, you will be writing methods to convert temperature between Fahrenheit and Celsius and length between meters and inches and practicing overloading methods. See the API document for the Conversion class for a list of the methods you will write. Also, because all of the methods of the Conversion class will be static, you should ensure that it is...
Create a class called Sphere. The class will contain the following    Instance data double radius...
Create a class called Sphere. The class will contain the following    Instance data double radius Methods Constructor with one parameter which will be used to set the radius instance data Getter and Setter for radius             Area - calculate the area of the sphere (4 * PI * radius * radius)             Volume - calculate and return the volume of the sphere (4/3 * PIE * radius * radius * radius) toString - returns a string with the...
In C++ Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string...
In C++ Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string • speed : float Create a FigherPlane class that inherits from the Airplane class and adds the following attributes: • numberOfMissiles : short
Create a class defined for Regression. Class attributes are data points for x, y, the slope and the intercept for the regression line.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT