import java.util.Scanner; /** * A simple program to calculate a restaurant tip. * * @author Sam Scott */ public class TipCalculator { //tip public static void main(String[] args) { //main Scanner sc = new Scanner(System.in); System.out.print("Enter the restaurant name: "); String name = sc.nextLine(); System.out.print("Enter the bill amount: "); double amount = sc.nextDouble(); sc.nextLine(); //clear the line System.out.print("Enter the percentage tip: "); int tipPercent = sc.nextInt(); sc.nextLine(); //clear the line double total = amount + calcTip(amount, tipPercent); System.out.printf("To give a %d%% tip at %s, you should pay $%.2f", 15, name, total); } //main /** * * Calc tip - Calculates the total restaurant bill with tip included. * @author Dave Slemon * * @param amount the amount of the bill without tip or taxes * @param percent the tip percentage * @return double the tip amount */ public static double calcTip(double amount, int percent) {//calcTip double totalTip = 0.0; totalTip = amount * percent / 100; return totalTip; }//calcTip } //tip