Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to calculate the total amount of a restaurant bill. The program will prompt the user to enter name of the customer,

Write a program to calculate the total amount of a restaurant bill. The program will prompt the user to enter 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 Price Amount Item Apple Poir Carrol Total: $23.5 Do you want to continue

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

What are conversion costs? What are prime costs?

Answered: 1 week ago

Question

7. How does caffeine increase arousal?

Answered: 1 week ago

Question

3. During which part of a nights sleep is REM most common?

Answered: 1 week ago