Question

#include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem;...

#include <iostream>

#include <iomanip>

#include <vector>

#include <string>

using namespace std;

struct menuItemType

{

string menuItem;

double menuPrice;

};

void getData(menuItemType menuList[]);

void showMenu(menuItemType menuList[], int x);

void printCheck(menuItemType menuList[], int menuOrder[], int x);

int main()

{

const int menuItems = 8;

menuItemType menuList[menuItems];

int menuOrder[menuItems] = {0};

int orderChoice = 0;

bool ordering = true;

int count = 0;

getData(menuList);

showMenu(menuList, menuItems);

while(ordering)

{

cout << "Enter the number for the item you would\n"

<< "like to order, or enter [0] to complete your order."<< endl;

cin >> orderChoice;

if (orderChoice > 0 && orderChoice <= menuItems)

{

menuOrder[orderChoice - 1] += 1;

}

else

ordering = false;

}

printCheck(menuList, menuOrder, menuItems);

cin.ignore(2);

return 0;

}

void getData(menuItemType menuList[])

{

menuItemType plainEgg;

menuItemType baconEgg;

menuItemType muffin;

menuItemType frenchToast;

menuItemType fruitBasket;

menuItemType cereal;

menuItemType coffee;

menuItemType tea;

plainEgg.menuItem = "Plain Egg";

plainEgg.menuPrice = 1.45;

baconEgg.menuItem = "Bacon and Egg";

baconEgg.menuPrice = 2.45;

muffin.menuItem = "Muffin";

muffin.menuPrice = 0.99;

frenchToast.menuItem = "French Toast";

frenchToast.menuPrice = 1.99;

fruitBasket.menuItem = "Fruit Basket";

fruitBasket.menuPrice = 2.49;

cereal.menuItem = "Cereal";

cereal.menuPrice = 0.69;

coffee.menuItem = "Coffee";

coffee.menuPrice = 0.50;

tea.menuItem = "Tea";

tea.menuPrice = 0.75;

menuList[0] = plainEgg;

menuList[1] = baconEgg;

menuList[2] = muffin;

menuList[3] = frenchToast;

menuList[4] = fruitBasket;

menuList[5] = cereal;

menuList[6] = coffee;

menuList[7] = tea;

}

void showMenu(menuItemType menuList[], int x)

{

int count;

cout << "Welcome to the restaurant" << endl;

cout << "What would you to order?" << endl;

for(count = 0; count < x; count++)

{

cout << setw(2) << left << "[" << count + 1 << "]"

<< menuList[count].menuItem << '$'

<< menuList[count].menuPrice << endl;

}

}

void printCheck(menuItemType menuList[], int menuOrder[], int menuItems)

{

double checkTotal = 0;

double checkTax = 0;

const double TAX = .05;

cout << "Thanks for eating"<< "Customer check: " << endl;

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

{

if(menuOrder[i] > 0) {

cout << setprecision(3) << setw(10) << left << menuList[i].menuItem

<< '$' << (menuList[i].menuPrice * menuOrder[i]) << endl;

checkTotal += (menuList[i].menuPrice * menuOrder[i]);

}

}

checkTax = checkTotal * TAX;

checkTotal += checkTax;

cout << setw(14) << left << "Tax" << checkTax << endl

<< setw(14) << left << "Total" << checkTotal << endl;

}

rewrite the code above (Breakfast billing system) using class.

Write a 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.

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

Use an array, menuList, of the struct menuItemType, with three components: menuItem of string, menuPrice of type double, and Count of type int. Your program must contain at least the following functions:

Function getData: This function loads the data from a file named menu.txt with the above breakfast items 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.)

A sample output is:

Welcome to Johnny’s Restaurant

Bacon and Egg             1          $2.45

Muffin                         1          $0.99

Coffee                          2          $1.00

Amount Total                          $4.44

Tax                                          $0.22

Amount Due                            $4.66

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
#include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

  • c++ Write a C++ program using the struct keyword to help a local restaurant automate its...

    c++ Write a C++ program using the struct keyword 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. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item) Menu Plain...

  • #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...

    #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car { private: string reportingMark; int carNumber; string kind; bool loaded; string choice; string destination; public: Car() { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car() { } void setUpCar(string &reportingMark, int &carNumber, string &kind, bool &loaded, string &destination); }; void input(string &reportingMark, int &carNumber, string &kind, bool &loaded,string choice, string &destination); void output(string &reportingMark, int &carNumber,...

  • #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part,...

    #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part, your program loads a vending machine serving cold drinks. You start with many foods, some are drinks. Your code loads a vending machine from foods, or, it uses water as a default drink. Create class Drink, make an array of drinks, load it and display it. Part 1 steps: [5 points] Create a class called Drink that contains information about a single drink. Provide...

  • This is C++ code for parking fee management program #include <iostream> #include <iomanip> using namespace std;...

    This is C++ code for parking fee management program #include <iostream> #include <iomanip> using namespace std; void input(char& car, int& ihour,int& imin, int& ohour, int& omin); void time(char car, int ihour, int imin, int ohour, int omin, int& phour, int& pmin, int& round, double& total); void parkingCharge (char car, int round, double& total); void print(char car, int ihour, int imin, int ohour, int omin, int phour, int pmin, int round, double total); int main() { char car; int ihour; int...

  • #include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS =...

    #include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS = 8; vector <double> inverse(NUM_ITEMS); int j; double temp; for (int i = 0; i < NUM_ITEMS; i++) { inverse.at(i) = 1 / (i + 1.0); } cout << fixed << setprecision(2); cout << "Original vector..." << endl; for (int i = 0; i < NUM_ITEMS; i++) { cout << inverse.at(i) << " "; } cout << endl; cout << "Reversed vector..." << endl; for...

  • Assume that a restaurant offers the following breakfast items: Plain Egg $1.45 Bacon and Egg $2.45...

    Assume that a restaurant offers the following breakfast items: 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 Write a program that stores the following data about each menu item in a structure called MenuItem: • A description of the menu item • The price of the menu item • A count of the number of times the item has been ordered
 The program should keep an array...

  • #include <iostream> #include <cmath> #include <iomanip> #include <cstdlib> using namespace std; bool isInt (double value) {...

    #include <iostream> #include <cmath> #include <iomanip> #include <cstdlib> using namespace std; bool isInt (double value) {     double dummy;     return bool(modf(value, &dummy) == 0); } double sqr(double value) { return value * value; } double calcFrictionFactor(double R, double D, double epsilon) {     const double BlasiusCoefficient = 0.3164;     double f_old, f_new;     f_new = BlasiusCoefficient * pow(R, -0.25); // loop until our two values are within 0.000001 of each other     do {   f_old = f_new; // previous guess is now the old one...

  • #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; struct transition{ // transition structure...

    #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; struct transition{ // transition structure char start_state, to_state; char symbol_read; }; void read_DFA(struct transition *t, char *f, int &final_states, int &transitions){ int i, j, count = 0; ifstream dfa_file; string line; stringstream ss; dfa_file.open("dfa.txt"); getline(dfa_file, line); // reading final states for(i = 0; i < line.length(); i++){ if(line[i] >= '0' && line[i] <= '9') f[count++] = line[i]; } final_states = count; // total number of final states // reading...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT