Question 1 (50 points): Restaurant Bil 1.1 (30 pts) In this program you will pro
ID: 3871913 • Letter: Q
Question
Question 1 (50 points): Restaurant Bil 1.1 (30 pts) In this program you will prompt the user to enter the charge for the meal and select a up rate (%10 for poor service, %15 for adequate service. %20 for good service). Your program will compute the tax and tip on a restaurant bill. The tax should be 6.25 percent of the meal charge. Display the meal charge. tax amount, tip amount, and total the screen. bill on 1.2 (20 pts) Modify the program 1.1 with the following: Prompt the user to enter the number of people who they will be served. .If there are more than 6 people, apply 25 percent for the tip. Display the meal charge, tax amount, tip amount, and total bill on the screen Note: If you write the code with modification, then just submit that java program. You don't need to submit 1.1 and 1.2 individually Your file will have the following documentation header: Title: 8 Purpose: To get familiar with simple calculations and comparison in Java eAuthor: (your last first name) Date: version: 1.0 LastNameFirstNameRestaurantBil1 (today's date)Explanation / Answer
import java.util.Scanner;
public class code
{
public static void main(String args[])
{
double charge, tip, tax, total;
String s = null;
Scanner d = new Scanner(System.in);
System.out.print("Enter the charge for the meal-");
charge = d.nextDouble();
Scanner in = new Scanner(System.in);
System.out.print("Enter the number of people-");
int num = in.nextInt();
if(num > 6)
tip = charge*0.25;
else
{
System.out.print("select service Quality good, adequate or poor -");
Scanner str = new Scanner(System.in);
s = str.nextLine();
if(s.equals("good"))
tip = charge*0.20;
else if(s.equals("adequate"))
tip = charge*0.15;
else
tip = charge*0.10;
}
tax = 0.0625 * charge;
total = charge + tax + tip;
System.out.println("Meal charge is-" + charge);
System.out.println("Tax is-" + tax);
System.out.println("Tip is-" + tip);
System.out.println("Total bill-" + total);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.