C++: Your job is to design a program to be used for a small local diner that all
ID: 3710030 • Letter: C
Question
C++:
Your job is to design a program to be used for a small local diner that allows customers to see the diner’s menu and then make their meal selections using the program. The program will also calculate and print an itemized bill. The diner menu MUST be saved to and retrieved from a text file that is used by the program each time it is initiated. Specifically, when the diner owner starts the program, the menu is loaded from the file and any changes to the menu are reflected in the contents of the text file so that the next time the diner owner starts the program, the new menu will be shown. The program is the only acceptable way to make changes to data in the text file to meet this problem statement. It is not acceptable to change the contents of the text file using a text editor.
Define a record (struct), menuItemType, with two components: menuItem of type string and menuPrice of type double. Use an array, menuList, of the struct menuItemType so that you just need to print the array to print the entire menu. The program should do the following:
Show the customer the different breakfast items offered by the restaurant.
Allow the customer to select more than one item from the menu.
Assign the customer a number from 0 to 99.
Calculate and print the bill with the customer number.
Save the customer’s selections and amount due in an array of records using their customer number as the index. Assuming that the diner will never have more than 100 customers at one time, the program can cycle back to index 0 when it reaches the end of the array at index 99.
Clear the screen for the next customer.
Although your team may decide to add items, assume that at the minimum the diner offers the following breakfast items (the price of each item is shown to the right of the item):
Two Scrambled Eggs $2.25
Bacon, Egg, and Cheese on a Hard Roll $3.25
Corn Muffin $1.49
French Toast Plate $3.99
Fruit Plate $3.49
Cereal and Milk $1.49
Coffee $1.50
Tea $1.00
Your program must contain at least the following functions:
Function getData: This function allows the restaurant owner to load the data into the array menuList from a text file that hold the menu information. You must also provide a facility for the owner to change menu items and prices. This facility must change the data in the text file so that the change can be used the next time the program is started.
Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items.
Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 8.125% tax.)
A sample output could be:
Welcome to the Diner!
Your Customer Order Number is 34
1 Bacon, Egg, and Cheese on a Hard Roll $3.25
2 Corn Muffin $2.98
1 Coffee $1.50
Total $7.73
Tax $0.63
Amount Due $8.36
Format your output with two decimal places. The name of each item in the output must be left justified.
Explanation / Answer
ANS:-
#include <iostream.h>
void showChoices();
float add(float, float);
float subtract(float, float);
float multiply(float, float);
float divide(float, float);
int main()
{
float x, y;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter your order: ";
cin >> x >> y;
cout << "Total ............................................................... $4.56
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.25,3.25) <<endl;
break;
case 2:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $6.12
Tax ................................................................. $0.63
Amount Due ................................................... $" << subtract(5.24,1.45) <<endl;
break;
case 3:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $5.23
Tax ................................................................. $0.63
Amount Due ................................................... $ " << multiply(2.1,1.5) <<endl;
break;
case 4:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $
Tax ................................................................. $0.63
Amount Due ................................................... $8.36 " << add(2.14,1.49) <<endl;
break;
case 5:
break;
case 6:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $2.99
Tax ................................................................. $0.63
Amount Due ................................................... $" << add(2.14,1.49) <<endl;
case 7:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $2.99
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.14,1.49) <<endl;
cas:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $7.74
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.14,3.49) <<endl;
default:
cout << "Invalid input" << endl;
}
}while (choice != 8);
return 0;
}
void showChoices()
{
cout << 1. Two Scrambled Eggs .................................. $2.25
2. Bacon, Egg, and Cheese on a Hard Roll ....... $3.25
3. Corn Muffin .............................................. $1.49
4. French Toast Plate ..................................... $3.99
5. Fruit Plate ................................................. $3.49
6. Cereal and Milk ......................................... $1.49
7. Coffee ...................................................... $1.50
8. Tea ........................................................... $1.00 << endl;
cout << "Enter your choice :";
}
float add(float a, float b)
{
return a+b;
}
float subtract(float a, float b)
{
return a-b;
}
float multiply(float a, float b)
{
return a*b;
}
float divide(float a, float b)
{
return a/b;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.