Set up one one-dimensional array for each field product


I. Write the class MailOrder to provide the following functions:

Set up one one-dimensional array for each field: product number (integer), unit price (double), and current inventory level (integer) in main memory to hold the above product information. There should be five rows (0 to 4) in each array, one for each item. For example, row 0 of the array for the product number is to hold the product number of product 1. Row 0 of the array for the unit price is to hold the unit price of product 1. Row 0 of the array for the current inventory level is to hold the current inventory level of product 1, etc.

The system should accept incoming sales orders until the user chooses to quit. In each sales order, a user can buy more than one item. For each item, the system accepts the product number and the quantity to be purchased. The system retrieves the correct unit price and current inventory level for that particular item. The system only sells up to the current inventory available. If the system can sell x pieces of this item in this order, the system calculates and displays the total amount for this item and also decreases the item inventory level by x immediately. When the user has finished keying in all the items of an order, the system displays the order total amount.

When the user says there are no more orders, the system displays the daily sales total. This is the total sales amount of all the orders processed. Then the system should end the execution of the system.

Detailed description of how the system should work is as follows:

When the system is run:

Display the following main question:

Please enter the next action ( a new order and ):

If the user enters any value other than 1 and 2, then the system displays an error message and displays the above question until the user has entered either 1 or 2.

If the user chooses entering a new order (1), then display the next product number question:
Please enter the next product number to buy (1 - 5 or -99 = end):

If the user enters a value that is not one of -99, 1, 2, 3, 4, and 5, then repeat this question again until the user has entered one of the acceptable values.

If user enters -99, this means the end of the current order:

Display order summary, for example:

Order Total Amount: $ 72.83

Add this order total amount to the daily sales total amount.

The system should go back to asking the main question, as shown above.

If the user enters 1, 2, 3, 4, or 5 (these are product numbers), this is the next item to be purchased:

If the current inventory level of this product is 0, display "This item is out of stock. Please pick another one." The system goes back to asking for the next product number, as shown above.

If the current inventory level is > 0, display "Unit Price: " and "Current Quantity Available: "
ask for the quantity ordered, "Enter quantity ordered: " .

If the quantity available is smaller than the quantity ordered, sell only the quantity available. Otherwise, sell the ordered quantity.

Display "Quantity Sold: "
Calculate the amount for this item as Unit Price * Quantity Sold.
Display the amount for this item: "Item Amount: $ "
Add this amount to the current order total amount.

Since this item has been sold, update the current inventory level of this item.

Repeat the above until the user enters -99 for the next product number to buy.

Then the system displays the main question again and repeats the above until the user enters a 2.

If the user chooses ending the whole order entry operation (2), then the system displays the daily sales total amount and ends the execution.

II. Write the class MailOrderTesting to provide the following functions:

In method main of this application, instantiate an object of MailOrder and call the method processOrders of this MailOrder object to start order processing.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Set up one one-dimensional array for each field product
Reference No:- TGS01030337

Expected delivery within 24 Hours