Question: C++ : Please complete all the To do in the following code to make it prints a menu of food items; allows the user
C++ :
Please complete all the " To do" in the following code to make it prints a menu of food items; allows the user to enter items for an order; calculates a subtotal, discount, and total; then prints a receipt.
#include
#include
#include
using namespace std;
const int NUM_MENU_ITEMS = 10; // num items on the menu
const int MAX_ORDER_ITEMS = 5; // max num of items per order
const double DISCOUNT_MIN = 20.00; // min subtotal to get discount
const double DISCOUNT_RATE = 0.25; // disc rate for highest-priced item
// Menu: parallel constant arrays
const string menuItem[NUM_MENU_ITEMS] = {
"Burger", "Hot Dog", "Chicken Fingers", "Fries",
"Tots", "Tea", "Coke", "Diet Coke", "Water", "Cookies" };
const double menuPrice[NUM_MENU_ITEMS] = {
3.50, 2.75, 4.25, 2.50, 3.25,
1.00, 1.25, 1.25, 0.25, 2.50 };
int main() {
// Order: parallel partial arrays of items ordered
// Each item has an item number, quantity ordered, and total price
// TODO: declare a list of item numbers
// TODO: declare a list of quantities
// TODO: declare a list of item prices (menu price X quantity)
// TODO: declare other variables as needed
// It is suppuse to b something similar to:
// const int Max= 500;
//int num = 0;
//string name[Max];
//int age[Max];
//Float gpa[Max];
// the same style but with appropriate variables.
double total, subtotal, discount;
// receipt line data
string recName;
int recQty;
double recPrice;
// print menu
cout
cout
cout
// TODO: write a loop to print the menu
{
cout
left
right
}
cout
// get order
cout
cout
cin >> ____ >> ____;
// TODO: repeat inputs until quantity is 0 or MAX_ORDER_ITEMS exceeded
{
//TODO: add an item to the order parallel arrays
cout
cin >> ____ >> ____;
}
// find the subtotal price
// TODO: use a loop to calculate the sum of all order prices
subtotal = 0;
// discount highest order line by 25% when total > $20
if (subtotal >= DISCOUNT_MIN) {
// TODO: add a loop to find the maximum item price
discount = DISCOUNT_RATE * maxItemPrice;
}
else
discount = 0;
// calculate the total price
total = subtotal - discount;
// print the receipt
cout
cout
cout
// TODO: use a loop to print the lines of the receipt
{
recName = ____;
recQty = ____;
recPrice = ____;
cout
}
cout
cout
cout
system("pause");
return 0;
}
It should do the following:


MENU: ## Iten Price 3.50 2.75 4.25 2.50 3.25 1.00 1.25 1.25 0.25 2.50 Burger 1 Hot Dog 0 2 ChickenFingers 3 Fries 4 Tots 5 Tea 6 Coke Diet Coke 8 Water 9 Cookies ty and menu item number 0 0 to end); Enter Item : 3 1 Item 1 1 4 Item 2:1 7 Item 3:0 0 - User inputs Item ty Price Hot Dog Tots Diet Coke 8.25 3.25 1.25 Subtotal: iscount: Total Price: 12.75 0.00 12.75 Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
