In C++ Design a modular, menu=driven program to help a local restaurant automate
ID: 3858000 • Letter: I
Question
In C++
Design a modular, menu=driven program to help a local restaurant automate its breakfast billing system. 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. They should be able to specify the number of each individual item they want.
Calculate and print the bill.
Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):
Plain Egg $1.45
Bacon and Egg $2.45
Muffin $0.99
French Toast $1.99
Fruit Basket $2.49
Cereal $0.69
Coffee $0.50
Tea $0.75
Here is a sample output:
Welcome to Johnny's Restaurant
1 Bacon and Egg $2.45
2 Muffin $1.98
1 Coffee $0.50
Tax $0.25
Amount Due $5.18
Your program should use a struct to store the individual menu items and an array of structs to store the menu. A data file is provided which has the menu item on a line followed by the price, followed by the next menu item, followed by its price, etc. Your program should use this file to initialize your menu.
Data file:
Please have
structure chart as a screen shot or picture
source code with
The name of your program as a comment at the top of the file
IPO chart incorporated as comments after the name of the file
IPO charts for your functions as comments before the prototypes of your functions
A screen shot or picture of the results after running your program with your test data
Explanation / Answer
Restra.cpp
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
struct mnuItm
{
string itemMn;
double priceMn;
};
void getDat(mnuItm mnList[]);
void dispMn(mnuItm mnList[], int io);
void chck(mnuItm mnList[], int order[], int io);
int main()
{
const int mnItems = 8;
mnuItm mnList[mnItems];
int order[mnItems] = {0};
int ch = 0;
bool orders = true;
int cnt = 0;
getDat(mnList);
dispMn(mnList, mnItems);
while(orders)
{
cout << "Please enter the number for the item you would "
<< "like to order, or enter [0] to complete your order."
<< endl;
cin >> ch;
if (ch > 0 && ch <= mnItems)
{
order[ch - 1] += 1;
}
else
orders = false;
}
chck(mnList, order, mnItems);
cin.ignore(2);
return 0;
}
void getDat(mnuItm mnList[])
{
mnuItm PEgg;
mnuItm bEgg;
mnuItm muff;
mnuItm fToast;
mnuItm fBAsk;
mnuItm cer;
mnuItm beans;
mnuItm chai;
PEgg.itemMn = "Plain Egg";
PEgg.priceMn = 1.45;
bEgg.itemMn = "Bacon and Egg";
bEgg.priceMn = 2.45;
muff.itemMn = "Muffin";
muff.priceMn = 0.99;
fToast.itemMn = "French Toast";
fToast.priceMn = 1.99;
fBAsk.itemMn = "Fruit Basket";
fBAsk.priceMn = 2.49;
cer.itemMn = "Cereal";
cer.priceMn = 0.69;
beans.itemMn = "Coffee";
beans.priceMn = 0.50;
chai.itemMn = "Tea";
chai.priceMn = 0.75;
mnList[0] = PEgg;
mnList[1] = bEgg;
mnList[2] = muff;
mnList[3] = fToast;
mnList[4] = fBAsk;
mnList[5] = cer;
mnList[6] = beans;
mnList[7] = chai;
}
void dispMn(mnuItm mnList[], int io)
{
int cnt;
cout << "Welcome to Akshay Cafe!" << endl;
cout << "What would you to order?" << endl;
for(cnt = 0; cnt < io; cnt++)
{
cout << setw(2) << left << "[" << cnt + 1 << "]"
<< mnList[cnt].itemMn << '$'
<< mnList[cnt].priceMn << endl;
}
}
void chck(mnuItm mnList[], int order[], int mnItems)
{
double chckTtl = 0;
double chckTax = 0;
const double RATE = .05;
cout << "Thanks for eating at Akshay Cafe!"
<< "Customer check: " << endl;
for(int i = 0; i < mnItems; i++)
{
if(order[i] > 0) {
cout << setprecision(3) << setw(10) << left << mnList[i].itemMn
<< '$' << (mnList[i].priceMn * order[i]) << endl;
chckTtl += (mnList[i].priceMn * order[i]);
}
}
chckTax = chckTtl * RATE;
chckTtl += chckTax;
cout << setw(14) << left << "Tax" << chckTax << endl
<< setw(14) << left << "Total" << chckTtl << endl;
}