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

Complete the algorithm table to calculate a tip to leave a waiter. The program s

ID: 3843962 • Letter: C

Question

Complete the algorithm table to calculate a tip to leave a waiter. The program should subtract the liquor and 7% tax from the total bill and then calculate the tip (using a percentage) on the remainder.  The user will enter the total bill, liquor amount, and tip percent. Desk check using $100 as total bill, $20 for liquor, and a 20% tip. When finished submit this document (not zipped) into Blackboard and submit hard copy in class. Field names are descriptive names in camel case.

See Sample Algorithm table.

Explanation / Answer

PROGRAM CODE:

import java.util.*;
import java.lang.*;
import java.io.*;


public class TipCalculator
{
   public static void main (String[] args) throws java.lang.Exception
   {
       Scanner keyboard = new Scanner(System.in);
       double totalBill, liquorAmount, tax = 7, tipPercent, tipAmount;
      
       //reading values from user
       System.out.print("Enter total bill amount:");
       totalBill = keyboard.nextDouble();
      
       System.out.print(" Enter liquor amount:");
       liquorAmount = keyboard.nextDouble();
      
       System.out.print(" Enter tax:");
       tipPercent = keyboard.nextDouble();
      
       //deducting tax from total bill
       totalBill = totalBill - (totalBill*tax)/100;
      
       //calculating tip amount
       tipAmount = (totalBill - liquorAmount)*tipPercent/100;
       System.out.print(" Tip Amount is " + tipAmount);  
   }
}

OUTPUT:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote