// Allison Obourn
// CS 141, Winter 2021
// Lecture 6

// This program prompts the user for a number of people and then prompts
// them for the cost of a meal for each person. It then prints out the subtotal,
// tax, tip and total of a restaurant bill

import java.util.*;

public class Receipt {
    public static void main(String[] args) {
    
        Scanner console = new Scanner(System.in);
        System.out.print("How many people ate? ");
        int people = console.nextInt();
        
        double subtotal = 0;
        for(int i = 0; i < people; i++) {
            System.out.print("Person #" + (i + 1) + ": How much did your dinner cost? ");
            double cost = console.nextDouble();
            subtotal += cost;
        }
        
        printResults(subtotal);
    }
    
    // prints the subtotal, tax, tip and total owed, assuming 8% tax / 15% tip
    public static void printResults(double subtotal) {
        double tax = subtotal * .08;
        double tip = subtotal * 0.15;
        
        System.out.println("Subtotal: " + subtotal);
        System.out.println("Tax: " + tax);
        System.out.println("Tip: " + tip);
        System.out.println("Total: " + (subtotal + tip + tax));
    }
}
