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: 50% (8 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...
-
Based on the information provided in Problem 11-11A, prepare a schedule of accounts payable for Flints Fantasy as of July 31, 20--. Verify that the accounts payable account balance in the general...
-
Placer Industries acquired 80 percent of SAS Shoes several years ago. Placer and SAS have made several intercompany transfers of depreciable assets over the years. Details are below. On June 30,...
-
Wood County Hospital consumes 1,000 boxes of bandages per week. The price of bandages is $35 per box, and the hospital operates 52 weeks per year. The cost of processing an order is $15 and the cost...
-
Please ans fast. Q1 (20 marks) Alter bridge is weighing a lease versus a purchase of some new machinery. The purchase price is $231,800. The equipment has a 4-year life after which time it is...
-
The financial statements of Columbia Sportswear Company are presented in Appendix B. Financial statements of Under Armour, Inc. are presented in Appendix C. Instructions a. Based on the information...
-
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* // /*** ******* ////************ **\\\\ *** *** **...
-
A sonnet is a 14-line poem in which certain rhyming patterns are followed. The writer Raymond Queneau published a book containing just 10 sonnets, each on a different page. However, these were...
-
Retained Earnings Balance (before Net Income) Paid-in Capital in Excess of Par Totals 80,690 82,690 $12,352,970 $12,352,970 -/50 !!! Prepare a balance sheet at December 31, 2025, for Novak...
-
People tend to think that an airline is to transfer passengers from one location to another. But is this simply the sole purpose of an airline? Impian airlines mission is to establish itself as the...
-
You and a friend are walking towards your bus stop when her boy friend stops her to ask about the weekend. You keep walking at a constant velocity of 0 . 9 4 m / s and reach the bus 5 . 6 8 minutes...
-
Provide a critical anaylysis of the different market structures, such as perfect competition, mnopolistic competition, oligopo and monopoly and how they differ in terms of the number of firms,...
-
a Divorce Complaint a divorce decree. A portion of your grade for the project will be based on your work here and your assessment of yourself and your classmates, concerning your teamwork skills. At...
-
You have a great idea for an Internet-based start-up business. A friend advises you to clearly link your business idea to potential customers and then describe it well in a business plan. "You won't...
-
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.
-
What type of meat does shari typically restrict consumption of ? Question 9 Answer a . chicken b . pork c . beef d . venison
-
QUESTION 1 8 In the bond market, the bond demanders are the _ _ _ _ _ _ _ _ and the bond suppliers are the _ _ _ _ _ _ _ _ . A . lenders; borrowers B . lenders; advancers C . borrowers; lenders D ....
-
If a technological advancement becomes available, the demand for _ _ _ _ _ _ _ _ labor may decrease because the new tech may be viewed as a _ _ _ _ _ _ _ . Question 2 options: a ) high - skill;...
Study smarter with the SolutionInn App