Related questions
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) | 1ドル.99 |
| Golden-Brown Pancake | 1ドル.99 |
| French Toast | 2ドル.99 |
| Muffin | 0ドル.99 |
| Bagel w/ Spread | 1ドル.20 |
| Fresh Fruit | 3ドル.49 |
| Steel-Cut Irish Oatmeal | 4ドル.69 |
| Coffee | 1ドル.50 |
| Pot of Assorted Tea | 1ドル.75 |
| Hot Chocolate | 1ドル.75 |
Define a struct named MenuItem with two components: name of type string and price of type double. Use an array of the struct MenuItem to store each menu item and a parallel array to store the quantity of each item a customer orders.
Your program must contain at least the following functions:
- Function getData: This function loads the item and price data from a text file named menu.txt (with a lowercase m) into the array of MenuItems. You will need to create the text file that contains this menu information. Format your text file so that it works well for your program (you may pick the format). This function should have two parameters: (1) an array of MenuItems and (2) the array length. The function should return the number of items read from the file.
Hint: If you use getline() to read the entire line as each menu item’s name, you will need to ignore the rest of the line after reading in the price as a double. There is also a 3-parameter overload of getline() that allows you to change the default delimiter ('\n') to another character like a tab ('\t').
- Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items. As expected, this function will need access to the MenuItems and know the number of items. It should not modify the MenuItems, so make that first parameter const. The function should show the welcome message first as shown in the example output below.
- Function makeSelection: This function repeatedly asks the customer if they would like to make a selection until the enter an N or n. If the customer enters Y or y, the program gets a menu item by number and a quantity from the customer. Validate the user input and store the quantities of each item purchased in a parallel array of integers. This function should not reference or modify the menuList array. See the example output below for what prompts to provide. If the user selects the same item number twice, replace the original quantity with the latest quantity.
- Function printReceipt: This function calculates and prints the check. It requires the two parallel arrays as parameters: (1) the MenuItem array, (2) the int array, and (3) the array size. (Note that the billing amount should include a 7% sales tax.)
Format your output as shown in the example. The name of each item in the output must be left justified. Right justify the price and quantities.
Upload your source code (Restaurant.cpp) and the text file with the menu information.
In C++
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- uppose you have a certain amount of money in a savings account that earns compoundmonthly interest, and you want to calculate the amount that you will have after a specificnumber of months. The formula, which is known as the future value formula, is:F=×ばつ(1+i)tThe terms in the formula are as follows:o F is the future value of the account after the specified time period.o P is the present value of the account.o i is the monthly interest rate.o t is the number of months.Write a program that prompts the user to enter the account’s present value, monthlyinterest rate, and the number of months that the money will be left in the account. Theprogram should pass these values to a function named futureValue that returns thefuture value of the account, after the specified number of months. The program shoulddisplay the account’s future value. i attached the screenshot of the output so the output should look like that. the coding should be in c++arrow_forwardDirections: Write a program that will perform a casino game using C. Provide comments in the codeexplaining everything. See above deliverable instructions. Requirements: A menu will first appear asking the user to choose which game they would like to play. The userwill be able to choose between blackjack and roulette.The blackjack game will only play one hand at a time against the dealer. If the dealer and the user have the same,then it’s a draw. If you do not know how to play blackjack, then you might need to research the game.The roulette game will ask the user what numbers they would like to bet on. If the random number is chosen, thenthe user wins.Each game should ask the user how much money they would like to bet before the game starts. The user shouldhave a starting amount of money, once the user loses their money, the user will then need to stop playing. Expert Solutionarrow_forwardQuestion 2: Write a program to check responses of a student to the multiple-choice final exam. The final exam consists of 20 questions, and answer sheet is abedeabcdeabedeabcde. Your screen should look like: Please, write your answers: abbdeabbdeabbdeabbde Please, write your answers: or aaaaaaaaaaaaaaaaaaaa Your score is 16 out of 20. Your score is 4 out of 20.arrow_forward
- there are three seating categories at a stadium. for a softball game, class A seats are 30,ドル Class B seats are 20ドル and Class C seats are 15ドル. Write a program that asks how many tickets for each class of seats were sold and then displays the amount of income generated from ticket sales.arrow_forwardYou are a Chemistry major who has to create a program for first time chemistry lab users. The Erlenmeyer flask contains a nitric acid solution. When the student presses a button, 0.5 mL of NaOH solution can be added to a buret, which is set up over the Erlenmeyer flask. An indicator is added to the solution being titrated. The indicator is a substance that changes to blue when the reaction is complete (endpoint). You determine the amount of mixture that will cause this reaction to occur. Create a titration simulator that will allow a student to add up to 18 mL of titrant. Notify the student when the mixture turns blue. In Python please :)arrow_forwardIn cengage mindtap The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of 12%. Monthly payments are 5% of the listed purchase price, minus the down payment. Write a program that takes the purchase price as input. The program should display a table, with appropriate headers, of a payment schedule for the lifetime of the loan. Each row of the table should contain the following items: The month number (beginning with 1) The current total balance owed The interest owed for that month The amount of principal owed for that month The payment for that month The balance remaining after payment The amount of interest for a month is equal to balance ×ばつ rate / 12. The amount of principal for a month is equal to the monthly payment minus the interest owed.arrow_forward
- Write a program that generates a random number in the range of 1 through 1000, and asks the user to guess what the number is. If the user guess is higher than the random number, the program should display Too high, try again. If the users guess is lower than the random number, the program should display Too low, try again. If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over. If the user doesn't want to continue the game the user should type an appropriate stop symbol to terminate the program (such stop conditions were discussed in the class). For each game iteration, count the number of guesses made by the user and display them. The program should contain the following functions: check_guess(): this function checks if the user's guess is lower, higher or equal to the random number. random_gen(): function that generates one random number for one game iteration main(): the function where the program...arrow_forwardWrite a program to ask the user to enter "how many quizzes?" he/she has entered in a lecture. The program will ask the grade results of the number of quizzes entered. The program will show the quiz results and the average of the quizzes as an output. As an extra challenge, display the maximum quiz result as well. How many quizzes?6 Enter the grade of Enter the grade of Enter the grade of Enter the grade of Enter the grade of quiz 5 : 30 Enter the grade of quiz 6: 12 Avarage of quizzes: 49 Maximum of quizzes: 95 quiz 1: 30 quiz 2 : 95 quiz 3 : 88 quiz 4 : 52arrow_forwardWrite a program that calculate electricity bill. The program prompts the user to enter the amount of KWh units of electricity consumed, the task is to calculate the electricity bill total with the help of the below charges: • 1 to 50 units of total units - Unit price=10 • 50 to 100 units of total units - Unit price=15 • above 100 units - Unit price=20 Sample Runl: Enter the amount of KWh units U: 250 Total Bill: 4250 Explanation: Charge for the first 50 units - 10 50 500 Charge for the 50 to 100 units - 15 50 - 750 Charge for the 100 to 250 units - 20*150 - 3000 Sample Run2: Enter the amount of KWh units U: 95 Total Bill: 1175 Explanation: Charge for the first 100 units - 10*50 - 500 Charge for the 50 to 100 units - 15 45 675arrow_forward
- Using pythonarrow_forwardWrite a program that plays a dice game called "21" It is a variation on BlackJack where one player plays against the computer trying to get 21 or as close to 21 without going over. Here are the rules of the game: You will play with dice that have numbers from 1 to 11. To win, the player or the computer has to get to 21, or as close as possible without going over. If the player or computer goes over 21, they instantly lose. If there is a tie, the computer wins. Starting the game: The player is asked to give the computer a name. For now, we'll simply call the computer opponent, "computer." The game starts with rolling four dice. The first two dice are for the player. These two dice are added up and the total outputted to the screen. The other two dice are for the computer. Likewise, their total is outputted to the screen. Player: If a total of 21 has been reached by either the player or the computer, the game instantly stops and the winner is declared. Otherwise,...arrow_forwardereuarrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education