Question
c++
Write a C++ program using the struct keyword to help a local restaurant automate its breakfast billing system The program sho
0 0
Add a comment Improve this question Transcribed image text
Answer #1
 #include<iostream> #include <iomanip> using namespace std; typedef struct { string itemName; double itemPrice; }menuItemType; menuItemType* getData(); void showMenu(menuItemType* menuList); void printCheck(menuItemType* menuList, int itemCount[]); int main(){ menuItemType* menuList = getData(); showMenu(menuList); int itemCount[7] = {0,0,0,0,0,0,0}; int itemNo = 0; cout<<"Enter item number or 9 to check out: "; cin>>itemNo; while(itemNo != 9){ int quantity = 0; string itemName = menuList[itemNo-1].itemName; cout<<"Enter quantity of "<<itemName<<": "; cin>>quantity; itemCount[itemNo-1] += quantity; cout<<"Enter item number or 9 to check out: "; cin>>itemNo; } printCheck(menuList,itemCount); return 0; } menuItemType* getData(){ menuItemType* menuList = (menuItemType*) malloc(7*sizeof(menuItemType)); menuList[0].itemName = "Plain Egg"; menuList[0].itemPrice = 1.45; menuList[1].itemName = "Bacon and Egg"; menuList[1].itemPrice = 2.45; menuList[2].itemName = "Muffin"; menuList[2].itemPrice = 0.99; menuList[3].itemName = "French Toast"; menuList[3].itemPrice = 1.99; menuList[4].itemName = "Fruit Basket"; menuList[4].itemPrice = 2.49; menuList[5].itemName = "Cereal"; menuList[5].itemPrice = 0.69; menuList[6].itemName = "Coffee"; menuList[6].itemPrice = 0.50; return menuList; } void showMenu( menuItemType* menuList ){ int i,total = 40; for(i=0; i<18; i++) cout<<" "; cout<<"Menu"; for(i=0; i<18; i++) cout<<" "; cout<<endl; for(int itemNo=0; itemNo<7; itemNo++){ string itemName = menuList[itemNo].itemName; double itemPrice = menuList[itemNo].itemPrice; cout<<(itemNo+1)<<"."<<itemName; int numDots = 40-itemName.length()-7; for(i=0; i<numDots;i++) cout<<"."; cout<<"$"<<setprecision(2)<<fixed<<itemPrice<<endl; } cout<<endl; cout<<"Enter Correspping number to select the item and for checkout enter 9"<<endl; } void printCheck(menuItemType* menuList, int itemCount[]){ cout<<endl<<"Wellcome to Joe's Restaurent"<<endl; double totalPrice = 0; for(int itemNo=0; itemNo<7; itemNo++){ int quantity = itemCount[itemNo]; if(quantity>0){ string itemName = menuList[itemNo].itemName; double itemPrice = menuList[itemNo].itemPrice; cout<<quantity<<" "<<itemName; int spaces = 30-itemName.length()-7; for(int i=0; i<spaces; i++) cout<<" "; cout<<"$"<<setprecision(2)<<fixed<<quantity * itemPrice<<endl; totalPrice += quantity * itemPrice; } } for(int i=0; i<7; i++) cout<<" "; cout<<"Tax"; for(int i=0; i<15; i++) cout<<" "; cout<<"$"<<setprecision(2)<<fixed<<totalPrice*0.05<<endl; totalPrice += totalPrice*0.05; for(int i=0; i<30; i++) cout<<"-"; cout<<endl; cout<<" Amount Due"; for(int i=0; i<13; i++) cout<<" "; cout<<"$"<<setprecision(2)<<fixed<<totalPrice<<endl; free(menuList); }
Add a comment
Know the answer?
Add Answer to:
c++ Write a C++ program using the struct keyword to help a local restaurant automate its...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #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...

  • In C++ Programming Write a program in to help a local restaurant automate its breakfast

    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):Use an array menuList of type menuItemType, as defined in Programming Exercise 3. Your program must contain at least the...

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

  • IN C# Write a program to help a local restaurant automate its lunch billing system. The...

    IN C# Write a program to help a local restaurant automate its lunch billing system. The program should do the following: Show the customer the different lunch 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 lunch items (the price of each item is shown to the right of the item): Ham and Cheese Sandwich $5.00 Tuna Sandwich $6.00 Soup...

  • In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast...

    In C++ Programming Write a program in Restaurant.cpp 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): Name Price Egg (cooked to order)...

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • C++ HELP I need help with this program. I have done and compiled this program in...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...

  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • Write a program in C++ that simulates a soft drink machine. The program will need several...

    Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...

  • C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank...

    C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank you. NO FFLUSH. Problem 5 (40 points)-Write a program Submit orders.c (Note: you wil be dynamically allocating memory for this problem. The second argument on the command line will let you know how much memory you will be allocating. O points if you do not dynamically allocate) Chef Bartolomeo owns a very busy Italian restaurant. He has recently started accepting orders online and every...

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