The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant
Question:
The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant expressions using variables of appropriate types.
Transcribed Image Text:
// 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);
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 42% (7 reviews)
This program computes the total amount owed for a meal assuming 8 tax and a 15 tip pub...View the full answer
Answered By
Pushpinder Singh
Currently, I am PhD scholar with Indian Statistical problem, working in applied statistics and real life data problems. I have done several projects in Statistics especially Time Series data analysis, Regression Techniques.
I am Master in Statistics from Indian Institute of Technology, Kanpur.
I have been teaching students for various University entrance exams and passing grades in Graduation and Post-Graduation.I have expertise in solving problems in Statistics for more than 2 years now.I am a subject expert in Statistics with Assignmentpedia.com.
4.40+
3+ Reviews
10+ Question Solved
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted:
Students also viewed these Computer science questions
-
Modify the program Coin Tosses to toss coin n times and print out after every 100 tosses the proportion of heads minus 1/2. Do these numbers appear to approach 0 as n increases? Modify the program...
-
Truth table in C programming Please follow the instructions below and include comments and snipshot for explanation thanks. 1) Copy the C program below. This program generates the truth table for a...
-
Using the sample program results in Figure 5.33: a. How many levels of cache are there? b. What are the overall size and block size of the first-level cache? c. What is the miss penalty of the...
-
The pump shown below inputs 55 horsepower to the water (at 91% efficiency) as it pumps water from the ocean bay reservoir to the upper seawater reservoir (68F). The elevation difference between the...
-
Steam enters an adiabatic turbine at 6 MPa, 600C, and 80 m/s and leaves at 50 kPa, 100C, and 140 m/s. If the power output of the turbine is 5 MW, determine (a) The reversible power output and (b) The...
-
In Problem, find each limit, if it exists. x* 12 lim X -3 2 - 6
-
A machine is said to be reversible, if its efficiency is (a) equal to \(100 \%\) (b) less than \(50 \%\) (c) more than \(50 \%\) (d) equal to \(50 \%\)
-
United Resources Company obtained a charter from the state in January 2014, which authorized 200,000 shares of common stock , $1 par value. During the first year, the company earned $590,000 and the...
-
1. for (int i = 4; i < 6; i ++) { for (int j = 6; j < 11; j++) { if (j >= c) { break; } System.out.print(" " + i + j + " "); } } If we know that the output is " 46 47 48 56 57 58", what is the value...
-
Allie has bought a new apple orchard. The orchard has a single file of trees, numbered from 1 to N. Each tree has a certail number of ripe apples. Allie has a rule she wants to follow. She wants to...
-
Modify your DollarFigure program from the previous exercise to become a new program called DollarFigure2 that uses a global constant for the figures height. (You may want to make loop tables first.)...
-
Write a Java program called StarFigure that produces the following output. Use nested for loops to capture the structure of the figure. //// * **1* // /*** ******* ////************ **\\\\ *** *** **...
-
The standard deviations for the data in Table P2.4 have been calculated for you. Do these calculations for yourself, showing your working fully. Table P2.4 1 Calculate x x y for each set of values....
-
For fluid similar to water, if the velocity is doubled what will be the increase in the heat transfer coefficient? If the viscosity is doubled what will be the change in the heat transfer coefficient?
-
Estimate the electrodialysis power for a load of 10000 ohms, when the solution normality is 2, flow rate 10 m3/s, removal and current efficiencies of 65 and 75%, respectively, and number of cells is...
-
Identify another firm or firms that quickly gained network effects when, on the surface, it would seem other firms were positioned to dominate the market. Why did these firms win? What aspects were...
-
Air at 70C is heating solids at 30C by convection. The area of heat transfer is 10 cm2 and the heat transfer coefficient is 2 kJ/cm2/K/s. What is the rate of heat transfer? What are the techniques...
-
Derive the equation for the exit concentration of the solute as function of time for a continuous stirred adsorption unit when the solute is injected in the feed at time = 0 (the adsorption follows a...
-
A candle is placed 15.0 cm in front of a convex mirror. When the convex mirror is replaced with a plane mirror, the image moves 7.0 cm farther away from the mirror. Find the focal length of the...
-
Read the case study Richter: Information Technology at Hungarys Largest Pharma and answer the following question: How does the organization ensure the accuracy of the data it stores?
-
Show how to implement the stack ADT using only a priority queue and one additional integer instance variable.
-
Hillary claims that a postorder traversal of a heap will list its keys in nonincreasing order. Draw an example of a heap that proves her wrong.
-
Bill claims that a preorder traversal of a heap will list its keys in nondecreasing order. Draw an example of a heap that proves him wrong.
-
How does the implementation of a centralized database system impact the efficiency and data accuracy in a large retail organization?
-
Identify some processes related to a workplace, assess the benefits and concerns that may arise as a result of the relative sizes of P-time with respect to D-time. In a table include the benefits and...
-
industry competitors and customers analysis & develop a communications pla. Choose any company and analyze its industry, competitors and customers. Then either present theirs communications plan or...
Study smarter with the SolutionInn App