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

  • #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...

  • #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) {...

  • Use this code to create multiple functions. #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() {...

    Use this code to create multiple functions. #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() { cout << fixed << showpoint << setprecision(2); ofstream outFile; outFile.open("Feras's.txt"); outFile << "..Skinny Feras's Restaurant ..\n\n" << endl; int choise=10, quantity; float paid, SubTotal=0, Tax = .10, Total, RM, more; while(choise!=0) { system("cls"); cout << "\t**Welcome To Skinny Alsaif Restaurant Lol**" << endl; cout << "\nWhat would you like to have?" << endl; cout << "1. Burger." << endl; cout << "2. Pizza." <<...

  • #include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code...

    #include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code here } void fill(int arr[], int count){ for(int i = 0; i < count; i++){ cout << "Enter number: "; cin >> arr[i]; } } void display(int arr[], int count){ for(int i = 0; i < count; i++){ cout << arr[i] << endl; } } int main() { cout << "How many items: "; int count; cin >> count; int * arr = new...

  • please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName();...

    please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...

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
ADVERTISEMENT