import java.util.Scanner; /** * A simple program to calculate a restaurant tip. * * @author Sam Scott */ public class TipCalculator { public static void main(String[] args) { 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 + amount * tipPercent / 100; System.out.println("To give a " + tipPercent + "% tip at " + name + ", you should pay $" + total); System.out.printf("To give a %d%% tip at %s, you should pay $%.2f", tipPercent, name, total); } }