Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Needs to be in c++ visual studio and uniqe code Write a program to help a local

ID: 3915675 • Letter: N

Question

Needs to be in c++ visual studio and uniqe code

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. Each time an item is selected, its quantity ordered is increased
c. 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.98
French Toast $1.99
Fruit Basket $2.44
Cereal $0.69
Coffee $0.55
Tea $0.75

First, Define a struct, menuItemType, with three components: menuItem of type string, menuPrice of type double, menuOrdered of type integer. Then use an array, call it menuList, of the struct menuItemType. Your program must contain 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)

- noncompiling (-50)

- Must have a struct and it MUST be of type menuItemType (members: menuItem, menuPrice, quantity) (if not named that way (except quantity), -5 for not following directions)
- You variable of the struct can NOT have arrays within it (-5 if you do)
- In main, must have an array of the struct variable (-5 if not)
- Must have functions, at a minimum: getData, showMenu, and printCheck (-15 if no functions)… can have more of course

Explanation / Answer

#include<iostream>

#include<string>

//define MAX number of items as 8

#define MAX 8

using namespace std;

struct menuItemType

{

string menuItem;

double menuPrice;

int menuOrdered;

};

void getData(menuItemType list[],int &n);

void showMenu();

void printCheck(menuItemType list[],int n);

double getPrice(int index);

string getItemName(int index);

int main()

{

menuItemType menuList[MAX];

int n = 0;

char choice;

do

{

showMenu();

//getData

getData(menuList, n);

printCheck(menuList, n);

cout << "Another costumer?(y/n)" << endl;

cin >> choice;

n = 0;

} while (choice != 'n');

cout << "Bye..... ";

}

double getPrice(int index)

{

//price of items stored in array

double price[8] = { 1.45,2.45,0.98,1.99,2.44,0.69,0.55,0.75 };

if (index > 8 || index < 1)

return -1;

else

return price[index - 1];

}

string getItemName(int index)

{

string items[8] = { "Plain Egg","Bacon and Egg","Muffin","French Toast","Fruit Basket","Cereal","Coffe","Tea" };

if (index > 8 || index < 1)

return "";

else

return items[index - 1];

}

void getData(menuItemType list[], int &n)

{

char choice;

int index;

do

{

cout << "Slect the items from Menu " << endl;

cout << "Select the number from the menu to select the menuItem(ex 1 for Plain egg): ";

cin >> index;

list[n].menuItem = getItemName(index);

cout << "Enter the quantity of the item: ";

cin >> list[n].menuOrdered;

//get index of item

list[n].menuItem = getItemName(index);

if (list[n].menuItem == "")

{

cout << "an error occured while selecting an item, please enter again.." << endl;

continue;

}

//get price of the item

list[n].menuPrice = getPrice(index);

if (list[n].menuPrice < 0)

{

cout << "an error occured while getting item price, please enter again.." << endl;

continue;

}

cout << "Are u done with selection of items(y/n)? ";

cin >> choice;

++n;

} while (choice != 'y');

}

void showMenu()

{

cout << "1. Plain Egg $1.45" << endl;

cout << "2. Bacon and Egg $2.45" << endl;

cout << "3. Muffin $0.98" << endl;

cout << "4. French Toast $1.99" << endl;

cout << "5. Fruit Basket $2.44" << endl;

cout << "6. Cereal $0.69" << endl;

cout << "7. Coffe $0.55" << endl;

cout << "8. Tea $0.75" << endl;

}

void printCheck(menuItemType list[], int n)

{

double sum=0;

double total;

cout << " #########Welcome###############" << endl;

cout << " Your bill " << endl;

for (int i = 0; i < n; i++)

{

if (list[i].menuOrdered > 0)

{

cout << "Item name : " << list[i].menuItem << endl;

cout << "Quantity ordered : " << list[i].menuOrdered << endl;

sum += list[i].menuPrice*list[i].menuOrdered;

}

}

//add 5% tax

total = sum+sum * 0.05;

cout << "Total : " << sum << endl;

cout << "Amount due after adding 5% tax: $" << total << endl;

cout << " Thank You " << endl;

}

/*output

1. Plain Egg $1.45

2. Bacon and Egg $2.45

3. Muffin $0.98

4. French Toast $1.99

5. Fruit Basket $2.44

6. Cereal $0.69

7. Coffe $0.55

8. Tea $0.75

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 1

Enter the quantity of the item: 2

Are u done with selection of items(y/n)? n

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 2

Enter the quantity of the item: 4

Are u done with selection of items(y/n)? y

#########Welcome###############

Your bill

Item name : Plain Egg

Quantity ordered : 2

Item name : Bacon and Egg

Quantity ordered : 4

Total : 12.7

Amount due after adding 5% tax: $13.335

Thanks You

Another costumer?(y/n)

y

1. Plain Egg $1.45

2. Bacon and Egg $2.45

3. Muffin $0.98

4. French Toast $1.99

5. Fruit Basket $2.44

6. Cereal $0.69

7. Coffe $0.55

8. Tea $0.75

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 1

Enter the quantity of the item: 2

Are u done with selection of items(y/n)? n

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 8

Enter the quantity of the item: 2

Are u done with selection of items(y/n)? n

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 4

Enter the quantity of the item: 3

Are u done with selection of items(y/n)? n

Slect the items from Menu

Select the number from the menu to select the menuItem(ex 1 for Plain egg): 5

Enter the quantity of the item: 2

Are u done with selection of items(y/n)? y

#########Welcome###############

Your bill

Item name : Plain Egg

Quantity ordered : 2

Item name : Tea

Quantity ordered : 2

Item name : French Toast

Quantity ordered : 3

Item name : Fruit Basket

Quantity ordered : 2

Total : 15.25

Amount due after adding 5% tax: $16.0125

Thank You

Another costumer?(y/n)

n

Bye.....

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote