Question
C++: I've tried everything but I can't seem to figure out this problem. Thank you in advance. Write a program to help a local restaurant
C++: I've tried everything but I can't seem to figure out this problem. Thank you in advance.
Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:
- a: Show the customer the different breakfast items offered by the restaurant.
- b: Allow the customer to select more than one item from the menu.
- c: Calculate and print the bill.
Item | Price |
---|---|
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 |
Use an array, menuList, of the struct menuItemType. Your program must contain at least the following functions:
- Function getData: This function loads the data into the array menuList.
- 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 5% tax.)
main.cpp template
#include
using namespace std;
const int NO_OF_ITEMS = 8;
int main() { menuItemType menuList[NO_OF_ITEMS]; int choiceList[NO_OF_ITEMS]; int choiceListLength;
ifstream inFile;
cout << fixed << showpoint << setprecision(2);
inFile.open("breakfasts.txt");
if (!inFile) { cout << "Cannot open the input file. Program Terminates!" << endl; return 1; }
// call getData // call showMenu // call makeSelection // call printCheck
return 0; } ====================
functions.cpp template
#include
using namespace std;
// struct for menuItemType
// load data from file inline void getData(ifstream& inFile, menuItemType mList[], int listSize) { // function code }
// part a inline void showMenu(menuItemType mList[], int listSize) { // function code }
// part c inline void printCheck(menuItemType mList[], int listSize, int cList[], int cListLength) { // function code }
inline bool isItemSelected(int cList[], int cListLength, int itemNo) { // function code }
// part b inline void makeSelection(menuItemType mList[], int listSize, int cList[], int& cListLength) { // function code }
====================
breakfasts.txt
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started