// CSE 142, Summer 2008 (Marty Stepp) // This program calculates and displays the total owed for a restaurant bill. // This version prompts the user for the tip percentage using Scanner. import java.util.*; // so that I can use Scanner public class Receipt2 { public static void main(String[] args) { // read user input for tip amount Scanner console = new Scanner(System.in); System.out.println("What percent tip do you want to leave?"); int percent = Math.max(0, console.nextInt()); // compute the various amounts double subtotal = 38 + 40 + 30; double tax = subtotal * .09; double tip = subtotal * (percent / 100.0); // .15; double total = subtotal + tax + tip; // output results System.out.println("Subtotal: " + subtotal); System.out.println("Tax: " + tax); System.out.println("Tip: " + tip); System.out.println("Total: " + total); } }