Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer the Question. Show all steps in order. The results should contribute to w

ID: 639678 • Letter: A

Question

Answer the Question. Show all steps in order. The results should contribute to what's in the message.

Write a program (Restaurant.java) that computes the tax and tip on a restaurant bill. The program should ask the user to enter the name of the waiter and the charge for the meal. The tax should be 6.75 percent of the meal charge. The tip should be 15 percent of the total after adding the tax. Display the waiter name, meal charge, tax amount, tip amount, and total bill on the screen. Output should look as follows if the waiter is Jim and the meal charge is $36. Use JOptionPane for output. See page 91.

Message:

Waiter Jim

Meal Charge $36.00

Tax $2.43

Tip $5.76

Total Bill $44.19

Explanation / Answer

Restaurent.Java

package com.charan;


  
   import javax.swing.JOptionPane;
   /**
   This program demonstrates using dialogs with
   JOptionPane.
   */
   public class Restaurant
   {
   public static void main(String[] args)
   {
       String name;
   String input; //For reader's input
   int total; // The user's total bill.
   int taxAmount; //6.75 of the user's total bill
   int totalMeal; //Bill after tax has been added
   int tip; // 15 percent of the totalMeal
   int overall; // The total including tax and tip
     
   // Get the user's total bill.
   name=
           JOptionPane.showInputDialog("enter waiter name:");
   input =
   JOptionPane.showInputDialog("What is " +
   "the total bill? ");
     
   //Convert the input to an int.
   total = Integer.parseInt(input);
   // Calculate the tax amount.
   taxAmount = (int) (6.75/100 * total);
   // Calculate the total meal after tax has been added.
   totalMeal = taxAmount + total;
   //Calculate the tip
   tip = 15/100 * totalMeal;
   // Calculate the entire bill.
   overall = totalMeal + tip;
     
   System.out.println("the waiter name:"+name);
   System.out.println("The taxed amount is " + taxAmount);
   System.out.println("The tip amount is " + tip);
   System.out.println("The total bill is " + overall);
   System.exit(0);
   }
   }