// CSE 142, Autumn 2010, Jessica Miller // This program uses variables to compute the bill at a restaurant. import java.util.*; public class Receipt2 { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("Welcome to Pho Shizzle Restaurant"); double subtotal = getDinners(console); System.out.println(); printReceipt(subtotal); } public static double getDinners(Scanner console) { System.out.print("How many people ate? "); int numPeeps = console.nextInt(); double subtotal = 0.0; for (int i = 1; i <= numPeeps; i++) { System.out.print("Person # " + i + ": How much? "); subtotal += console.nextDouble(); } return subtotal; } public static void printReceipt(double subtotal) { double tax = subtotal * .08; double tip = subtotal * .15; System.out.println("Subtotal: $" + subtotal); System.out.println("Tax: $" + tax); System.out.println("Tip: $" + tip); System.out.println("Total: $" + (subtotal + tip + tax)); } }