// Helene Martin, CSE 142 // Calculate total owed, assuming 8% tax / 15% tip import java.util.*; public class Receipt { public static void main(String[] args) { Scanner console = new Scanner(System.in); double subtotal = getSubtotal(console); double tax = subtotal * .08; double tip = subtotal * .15; double total = subtotal + tax + tip; System.out.println("Subtotal: " + subtotal); System.out.println("Tax: " + tax); System.out.println("Tip: " + tip); System.out.println("Total: " + total); } // Prompts for the number of people in attendance and their meal costs. // Returns the sum of the meal costs. public static double getSubtotal(Scanner console) { System.out.print("How many people? "); int people = console.nextInt(); double subtotal = 0; for (int i = 0; i < people; i++) { System.out.print("Meal " + (i + 1) + " cost? "); double cost = console.nextDouble(); subtotal += cost; // same as subtotal = subtotal + cost; } return subtotal; } }