Write a program to calculate the total amount of a restaurant bill. The program will prompt...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program to calculate the total amount of a restaurant bill. The program will prompt the user to enter name of the customer, and the name, price, and amount of 3 items. Then, the program will output name of the customer, and the name, price, and amount received, and calculate and display the total to pay. The program will ask user if s/he wants to continue. The user can input Y to continue or N to end. This question is similar to question 2 in HWI. However, you need to define methods to get name, price, and amount of items. These methods receive the item number as their argument, prompt user for input, and return the input value. Also, you need to define a method to receive the price and amount of 3 items and calculate and return the total. Then you need call the defined methods in the main method. Your program needs a loop to check if the user wants to continue. The definition of one of the required methods is provided for you below: public static String entertemName(int num) System.out.printf("Enter name for item No. %d: ", num); return in.nextLine(); Following is a sample of the program input and output: Sample Input: Enter customer name: Alex Enter name for item No. 1: Apple Enter price for item No. 1: 2.00 Enter amount for item No. 1:6 Enter name for item No. 2: Pear i Enter price for item No. 2: 1.001 Enter amount for item No. 2:4 Enter amour Enter name for item No. 3. Carrot Enter price for item No. 3: 1.50 Enter amount for item No. 3:5 Sample Output Customer Name: Alex Hem WWW Price Amount $2.00 6 $1.00 4 $1.50 5 wwww I Apple Pear Carrot Total: $23.5 Do you want to continue (Y/N) Y Enter cunomer Rose Enter name for nem No. 1: Orange Ester price for atom No 12.50 Enter sound for item No 1:21 Sample Output: Customer Name: Alex Price Amount Item Apple Poir Carrol Total: $23.5 Do you want to continue (Y/N): Y Enter customer name: Rose Enter name for item No. 1: Orange Enter price for item No. 1: 2.50 Enter amount for item No. 1:2 Enter name for item No. 2: Lemon Enter price for item No. 2: 1.50 Enter amount for item No. 2:31 Enter name for item No. 3: Apple Enter price for item No. 3: 2.00 Enter amount for item No. 3:41 $2.00 6 $1.00 4 $1.50 5 Customer Name: Rose The Orange Lemon Apple Price Amount $2.50 2 $1.50 3 $2.00 4 HEN Total: $17.5 Write a program to calculate the total amount of a restaurant bill. The program will prompt the user to enter name of the customer, and the name, price, and amount of 3 items. Then, the program will output name of the customer, and the name, price, and amount received, and calculate and display the total to pay. The program will ask user if s/he wants to continue. The user can input Y to continue or N to end. This question is similar to question 2 in HWI. However, you need to define methods to get name, price, and amount of items. These methods receive the item number as their argument, prompt user for input, and return the input value. Also, you need to define a method to receive the price and amount of 3 items and calculate and return the total. Then you need call the defined methods in the main method. Your program needs a loop to check if the user wants to continue. The definition of one of the required methods is provided for you below: public static String entertemName(int num) System.out.printf("Enter name for item No. %d: ", num); return in.nextLine(); Following is a sample of the program input and output: Sample Input: Enter customer name: Alex Enter name for item No. 1: Apple Enter price for item No. 1: 2.00 Enter amount for item No. 1:6 Enter name for item No. 2: Pear i Enter price for item No. 2: 1.001 Enter amount for item No. 2:4 Enter amour Enter name for item No. 3. Carrot Enter price for item No. 3: 1.50 Enter amount for item No. 3:5 Sample Output Customer Name: Alex Hem WWW Price Amount $2.00 6 $1.00 4 $1.50 5 wwww I Apple Pear Carrot Total: $23.5 Do you want to continue (Y/N) Y Enter cunomer Rose Enter name for nem No. 1: Orange Ester price for atom No 12.50 Enter sound for item No 1:21 Sample Output: Customer Name: Alex Price Amount Item Apple Poir Carrol Total: $23.5 Do you want to continue (Y/N): Y Enter customer name: Rose Enter name for item No. 1: Orange Enter price for item No. 1: 2.50 Enter amount for item No. 1:2 Enter name for item No. 2: Lemon Enter price for item No. 2: 1.50 Enter amount for item No. 2:31 Enter name for item No. 3: Apple Enter price for item No. 3: 2.00 Enter amount for item No. 3:41 $2.00 6 $1.00 4 $1.50 5 Customer Name: Rose The Orange Lemon Apple Price Amount $2.50 2 $1.50 3 $2.00 4 HEN Total: $17.5
Expert Answer:
Answer rating: 100% (QA)
Here is a Java program that calculates the total amount of a restaurant bill based on the users input It includes methods for getting item details and ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
1) Sleep More Corporation has pledged to pay a $10 per share dividend every year indefinitely. if you require an 11% return on your investment, how much will you pay for the company's shares today? ...
-
1. Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Data obtained from asking the wrong questions at the wrong time or in the wrong place can lead to misleading summary statistics. Explain why the following collection procedures are likely to produce...
-
A 50.0-kg block and a 100-kg block are connected by a string as in Figure P8.36. The pulley is frictionless and of negligible mass. The coefficient of kinetic friction between the 50.0 kg block and...
-
Telemark-Kjemi AS manufactures an industrial solvent in two departments - mixing and cooking. This question focuses on the Cooking Department. During June 2007, 90 tones of solvent were completed and...
-
True or False: Broken rotor bars are just as easily identified at rest as during full-load operation of the motor.
-
Same setup as Exercise 14.1, except that now EBV is considering two additional structures: Alternative I: A 2X liquidation preference on the RP; or Alternative II: A cumulative compound dividend of...
-
Attending Ms. Davina Jaid in relation to a road traffic accident on 12 March 2022 in which she was involved. Her full name is Davina Jaid and her date of birth is 14 May 2000. Ms Jaid suffered...
-
1. Select an organization (corporate or nonprofit) that uses both online and offline channels. Discuss two or three specific examples of how it is taking advantage of digital marketing, especially...
-
The primary coll of a transformer has N = 380 turns, and the secondary coil has N - 2 490 turns. If the input voltage across the primary coll is Av(t) = 170 cos cat, where Av is in volts and t is in...
-
Water, p=998 kg/m, p=0.001 Pa-s, flows through a rough pipe of diameter 3 cm at 30 m/h. If the surface roughness is 0.1 mm, compute: a) The Darcy's friction factor A and the skin friction coefficient...
-
Can you explain why 70000 is irrelevant costs and 80000, 100000 and 50000 is relevant costs? Xebex Pty Ltd is considering whether to make or buy a component used in the production of Faz Machines....
-
Please describe the Opportunity Risk for FedEx company & explain the following question for FedEx company's opportunity risk: a) Description of the risk and how it affects the organization (FedEx)?...
-
Briefly describe how creating norms of flexibility and autonomy and cultivating idealistic goals can encourage innovation in an organization.
-
Define securitized mortgages, or mortgage-backed securities. Describe one way in which this innovation helps banks (be specific).Also provide one way in which its misuse helped lead to the financial...
-
What is Differential Correction?
-
Decades after the event, Johnson & Johnson (J&J), the 130-year-old American multinational, is still praised for swiftly The company indicated that its response was based on the expectations set forth...
-
Sherry rents her vacation home for 6 months and lives in it for 6 months during the year. Her gross rental income during the year is $4,000. Total real estate taxes for the home are $950, and...
-
Sally and Charles Heck received the following dividends and interest during 2012: Assuming the Hecks file a joint tax return, complete Schedule B of Form 1040 (on page 2-33) for them for the 2012 tax...
-
Tom has a successful business with $100,000 of income in 2012. He purchases one new asset in 2012, a new machine which is 7-year MACRS property and costs $25,000. If you are Tom's tax advisor, how...
-
Consider two hypersonic wind tunnels with the same reservoir temperature of \(3000 \mathrm{~K}\) in air. (a) One tunnel has a test-section Mach number of 10. Calculate the flow velocity in the test...
-
The reservoir temperature calculated in problem 5.20 is beyond the capabilities of heaters in the reservoir of continuous-flow wind tunnels using air. This is why you do not see a Mach 20...
-
As problems 5.18 and 5.19 reflect, the air temperature in the test section of conventional hypersonic wind tunnels is low. In reality, air liquefies at a temperature of about \(50 \mathrm{~K}\)...
Study smarter with the SolutionInn App