Question: The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant expressions using variables of appropriate types. // This

The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant expressions using variables of appropriate types.

// This program computes the total amount owed for a meal, // assuming 8% tax and a 15% tip. public class Receipt { public static void main (String [] args) { System.out.println (

// This program computes the total amount owed for a meal, // assuming 8% tax and a 15% tip. public class Receipt { public static void main (String [] args) { System.out.println ("Subtotal:"); System.out.println (38 + 40 + 30); System.out.println ("Tax:"); System.out.println ((38 + 40 + 30) * .08); System.out.println ("Tip:"); System.out.println ( (38 + 40 + 30) * .15); System.out.println ("Total:"); System.out..println (38 + 40 + 30 + (38 + 40 + 30) * .08 + (38 + 40 + 30) * .15);

Step by Step Solution

3.32 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This program computes the total amount owed for a meal assuming 8 tax and a 15 tip pub... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!