import java.util.*; // This is a second version of the receipt program. This version begins // to use System.out.printf to print out the tax, total, tip, and subtotal // in a more professional way. In class we only got to fix subtotal. Try // yourself to fix tax, tip, and total to print out in the following format // $xxx.xx. public class Receipt2 { public static void main(String[] args) { // Calculate total owed, assuming 8% tax / 15% tip Scanner console = new Scanner(System.in); System.out.print("How many people ate? "); int numEaters = console.nextInt(); double subtotal = 0; for (int i = 1; i <= numEaters; i++) { System.out.print("#" + i + ": How much did your dinner cost? "); subtotal += console.nextDouble(); } double tax = subtotal * .08; double tip = subtotal * .15; System.out.printf("Subtotal: $%.2f\n", subtotal); System.out.println("Tax:"); System.out.println(tax); System.out.println("Tip:"); System.out.println(tip); System.out.println("Total:"); System.out.println(subtotal + tax + tip); } }