Question

In: Computer Science

1. Start a new customer order – clear the order data (give a second chance to...

1. Start a new customer order – clear the order data (give a second chance to not clear data)  This will clear all the running totals (set them to zero).

  1. Ordering Ice Cream Sundaes – should prompt the user for the number of ice cream sundaes.

  2. Ordering Ice Cream Cones – should prompt the user for the number of ice cream cones.

  3. Ordering Milkshakes – should prompt the user for the number of milkshakes.

  4. Generate the customer receipt for their order. This should be appended to any other

    orders already written to the file. The receipt output file should be named: receipt.rpt

  5. Exit the program - Make sure to exit the program gracefully through the return 0 at the

    bottom of main( ).

Write a menu driven program that will provide the user with the 6 menu options indicated above. The user should be able to make a selection, execute the code for that selection, and then return to the menu until option (6) Exit is selected. If the end-user enters an invalid menu option, print an error message and redisplay the menu, getting a new selection.

When an option from the menu is selected your program should call a function to do the selection processing. If the end-user enters a qty that is less than 0 or enters character data, print an error message and prompt the user for a new value. Keep a running total of how many of each item is ordered.

When the option to start a new order is selected, ask the user if they are sure they want to clear the order. If the user answers ‘y’ or ‘Y’ then clear the running totals for all ice cream products. Any other input should not clear the running totals.

When the end-user selects to create a receipt, write a summary of the items ordered (don't print items that have a count of zero), calculate the subtotal, tax (using 6%), and the total order to an output file named receipt.rpt (use append mode of opening the file so each order is appended to the end of the file). If the entire order is zero, do not generate a summary; simply write the line: No order was placed. Each receipt written should have a delimiter, a new line, line of “*”, and a new line. In c++

Solutions

Expert Solution

All the explanation is in the code comments. Hope this helps!

Code:

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
int flag = 0, choice, is = 0, ic = 0, m = 0, x;
// cost per item
double pis = 110.0, pic = 45.5, pm = 99.9;
double subtotal, tax, total;
  
// open file
ofstream fout;
fout.open("receipt.rpt", std::ios_base::app);
  
// run till exited
while(flag!=1)
{
// give options to user
cout << "1 - Clear the order data" << endl;
cout << "2 - Order Ice Cream Sundaes" << endl;
cout << "3 - Order Ice Cream Cones" << endl;
cout << "4 - Order Milkshakes" << endl;
cout << "5 - Generate receipt for order" << endl;
cout << "6 - Exit the program" << endl;
  
// user choice
cout << "Enter choice: ";
cin >> choice;
  
if(choice == 1)
{
string tmp;
// again ask if to be cleared
cout << "Are you sure you want to clear order (y/Y)?: ";
cin >> tmp;
if(tmp == "Y" || tmp == "y")
{
// set everything to 0
is = 0;
ic = 0;
m = 0;
}
}
else if(choice == 2)
{
// take input till valid is not found
while(true)
{
cout << "Enter quantity for Ice Cream Sundaes: ";
cin >> x;
if(x > 0)
break;
cout << "Quantity should be greater than 0" << endl;
}
// add to ice cream Sundaes
is += x;
}
else if(choice == 3)
{
// take input till valid is not found
while(true)
{
cout << "Enter quantity for Ice Cream Cones: ";
cin >> x;
if(x > 0)
break;
cout << "Quantity should be greater than 0" << endl;
}
//add to ice cream cones
ic += x;
}
else if(choice == 4)
{
// take input till valid is not found
while(true)
{
cout << "Enter quantity for Milkshakes: ";
cin >> x;
if(x > 0)
break;
cout << "Quantity should be greater than 0" << endl;
}
// add to Milkshakes
m += x;
}
else if(choice == 5)
{
// Generate receipt
if(ic == 0 && is == 0 && m==0)
fout << "No order was placed." << endl;
else
{
// print in the format required
if(is!=0)
fout << "Ice Cream Sundaes: " << is << endl;
if(ic!=0)
fout << "Ice Cream Cones: " << ic << endl;
if(m!=0)
fout << "Milkshakes: " << m << endl;
subtotal = pis*is + pic*ic + pm*m;
fout << "Subtotal: $" << subtotal << endl;
tax = (6*subtotal)/100;
fout << "Tax: $" << tax << endl;
total = subtotal + tax;
fout << "Total: $" << total << endl;
}
fout << "\n****************************************\n" << endl;
}
// exit by setting flag to 1
else if(choice == 6)
{
flag = 1;
}
else
{
// invalid choice
cout << "Wrong choice\n";
}
}
return 0;
}

Sample run:

input:

ouput file:

Code screenshots:


Related Solutions

Explain and give some examples on the change efforts for first order change and second order...
Explain and give some examples on the change efforts for first order change and second order change in an organization.
1. On December 1, Sage Hill accepted an order from a new customer, Buffalo Computers. Buffalo...
1. On December 1, Sage Hill accepted an order from a new customer, Buffalo Computers. Buffalo has a questionable credit history, so Sage Hill requires a $8,000 deposit from Buffalo in order to begin production on its order. 2. During December, cash sales at Sage Hill’s retail locations totaled $3,424,000, which includes the 7% sales tax Sage Hill must remit to the state by the fifteenth day of the following month. 3. During the year, Sage Hill was sued by...
A company is considering purchasing a new second machine in order to expand their business. The...
A company is considering purchasing a new second machine in order to expand their business. The information for the new machine is: Cost= $100,000 Increase in contribution margin= $25,000 Life of the machine= 5 years Required rate of return = 10% Calculate the following: a. Net present value (NPV) (Use factors to three decimal places, X.XXX, and use a minus sign or parentheses for a negative net present value. Enter the net present value of the investment rounded to the...
Explain why order management and customer service are not mutually exclusive. please give example
Explain why order management and customer service are not mutually exclusive. please give example
Kristin has decided to start a new business of baking and selling cookies to order and...
Kristin has decided to start a new business of baking and selling cookies to order and cater to the university students on campus when they study in the evenings and stay up till after midnight. She has named her business Cookie Cult. The following is the list of tasks she came up with for completing one cycle of cookie production. After a car arrives; inspector checks paper work and sets up machine Inspector collects payment for the service Inspector checks...
3. Give someone a chance to buy a good X at price $1 and they refuse....
3. Give someone a chance to buy a good X at price $1 and they refuse. But then, give them the good and ask them to sell it for $1 and, strangely, many times they refuse and demand a higher price. This is called the “endowment effect” - and in fact some evolutionary biologists believe it is an ingrained phenomenon that is completely explained when one looks at the long history from which we evolved. Economist John List investigated this...
Wizard Corporation has analyzed their customer and order handling data for the past year and has...
Wizard Corporation has analyzed their customer and order handling data for the past year and has determined the following costs: Order processing cost per order $7 Additional costs if order must be expedited (rushed) $8.00 Customer technical support calls (per call) $12 Relationship management costs (per customer per year) $1200 In addition to these costs, product costs amount to 75% of Sales. In the prior year, Wizard had the following experience with one of its customers, Chester Company: Sales $15,500...
Bert Asiago, as salesperson at Convertco, received an order from a potential new customer for 50,000...
Bert Asiago, as salesperson at Convertco, received an order from a potential new customer for 50,000 units of the company's single product. The price came in at $25 below the regular selling price of $65. Asiago knows that Convertco has the capacity to produce the product without affecting regular sales. He spoke to Bia Morgan, the controller, who informed him that at the $40 selling price, it's $42 of variable costs won't be covered. She recommends rejecting the order. Bert...
A sales manager collected the following data on annual sales for new customer accounts and the...
A sales manager collected the following data on annual sales for new customer accounts and the number of years of experience for a sample of  salespersons. Salesperson Years of Experience Annual Sales ($1000s) 1 1 80 2 3 76 3 4 72 4 6 77 5 8 92 6 8 109 7 9 126 8 9 122 9 10 124 10 11 120 The data on  annual sales  for new customer accounts and  number of years of experience for a sample of  salespersons provided the...
A sales manager collected data on annual sales for new customer accounts and the number of...
A sales manager collected data on annual sales for new customer accounts and the number of years of experience for a sample of 10 salespersons. In the Microsoft Excel Online file below you will find a sample of data on years of experience of the salesperson and annual sales. Conduct a regression analysis to explore the relationship between these two variables and then answer the following questions. Salesperson Years of Experience Annual Sales ($1000s) 1 3 79 2 4 92...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT