// Project: TerminalIO // Module: TipCalculator // Source code file: Main.java // Calculate the tip for a restaurant bill. // Always tip at least one dollar. import java.util.Scanner; public class Main { public static void main(String[] args) { // Create Scanner object. Scanner scanner = new Scanner(System.in); // Enter amount of bill and tip percentage. System.err.print("Enter the amount of bill: "); double amount = Double.parseDouble( scanner.nextLine( )); System.err.print("Enter tip percentage: "); double tipPercentage = Double.parseDouble( scanner.nextLine( )); // Calculate and print tip amount. double tipAmount = amount * tipPercentage / 100.0; if (tipAmount > 1.00) { System.out.println(String.format( "Amount of Tip: $%.2f", tipAmount)); } else { System.out.println(String.format( "Amount of Tip: $1.00")); } // Close scanner. scanner.close( ); } }