Consider the TestScores program below. In the above program, note how the following lines appear above the
Question:
Consider the TestScores program below.
In the above program, note how the following lines appear above the loop and also at the bottom of the loop:
Modify the program so it avoids having those lines appear twice but keeps the same functionality. For your modification, you are required to use a boolean variable named done in the while loop’s condition.
Transcribed Image Text:
/*** * TestScores.java * Dean & Dean * * This implements an algorithm that averages test scores. import java.util.Scanner; public class TestScores ( public static void main(String[] args) ( } Scanner stdIn new Scanner(System.in); int score; int scoreSum = 0; int count = 0; double average = 0; - System.out.print("Enter score (-1 to quit): "); score - stdIn.nextInt (); while (score >= 0) ( scoreSum + score; count++; average (double) score Sum / count; System.out.print("Enter score (-1 to quit): "); score = stdIn.nextInt(); System.out.println("Average score is + average); } // end main } // end TestScores class
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 60% (5 reviews)
To modify the program as described we can introduce a dowhile loop instead of a while loop This way ...View the full answer
Answered By
Utsab mitra
I have the expertise to deliver these subjects to college and higher-level students. The services would involve only solving assignments, homework help, and others.
I have experience in delivering these subjects for the last 6 years on a freelancing basis in different companies around the globe. I am CMA certified and CGMA UK. I have professional experience of 18 years in the industry involved in the manufacturing company and IT implementation experience of over 12 years.
I have delivered this help to students effortlessly, which is essential to give the students a good grade in their studies.
3.50+
2+ Reviews
10+ Question Solved
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted:
Students also viewed these Computer science questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
The site http://virtualpiano.net features an online player piano. If you click on the Key Assist menu just above the piano keyboard, and then Keyboard Keys, you will see that each key is labelled...
-
The number x of bicycle helmets people are willing to buy per week from a retail chain at a price of $p is given by x = 1,000 - 60p + 25 20 ¤ p ¤ 100 (see the figure). (A) Find dx/dp....
-
Show the products of thesereactions: CH3 HBr a) CH,CHCH-CH2 HBr b) PhC CH 2 HBr
-
On April 30, the bank reconciliation of Westbrook Company shows three outstanding checks: no. 254, $650; no. 255, $620; and no. 257, $410. The May bank statement and the May cash payments journal...
-
The prism in Figure P24.32 is symmetric (i.e., its face forms an isosceles triangle). If the ray showed is perpendicular to the bottom surface of the prism and just barely undergoes total internal...
-
1. Map Crayola's five pillars of operational leadership to the competitive priorities in Table 1.3. 2. Create an assessment of Crayola's competitive priorities as it relates to their Asian expansion...
-
This form of compensation involves either an hourly rate of payment or a lump-sum amount. commission-based mark-up charges fee system pay-for-results
-
Consider the following code fragment. Without changing the loop type, modify the code to prevent output when the input equals the sentinel value of zero. Scanner stdIn = new Scanner(System.in); int...
-
Given this main method: Trace the code using either the short form or the long form. To help you get started, heres the trace setup. For the short form, you wont need the line# column. 1 2 23 3 4 5 6...
-
Estimate the position and approximate value of the global maxima and minima on the region shown, including its boundary. 5x/2 2x 3x/2 k y /20- -0.50 50 -0.75 x/2 0.75 -0,75 -0.25 X
-
Admin Support Cereal Bars Square Foot 1,250 1,500 7,500 7,000 # of employees 14 11 42 59 # of machine batches 0 0 14 27 # of computers 17 21 35 30 Costs 32,000.32 21,740.21 The Support department...
-
Compare and contrast the differences between innovation and creativity. Does one lead to the other? If so, please explain. Why is innovation important? Who within the organization is responsible for...
-
Using the tables from Check your Consumer Surplus and Producer Surplus activities, find the equilibrium price and quantity in the market for cheese-stuffed jalapeno peppers. What is the total surplus...
-
We decided to use Gehan's two-stage design for this purpose. In the first stage, we will discard the new treatment if no patient out of n0 patients. Suppose the probability we can tolerate to discard...
-
Claude Haridge was involved in a demonstration. He threw a paint balloon at a bus and some of the paint flecks hits a nearby officer, so Haridge was transported to police cells. At the cells Special...
-
In Problems 49-60, find each indefinite integral and check the result by differentiating. a. b. c. d. e. f. x(a2 + 2) dx 2) dx 4 dx x In x
-
If the amplifier indicated by the box input impedance of oo, which of the following statements are true ? has an open loop gain as well as Feedback factor (\beta = 1/ R_1\) The feedback is voltage...
-
Explain how the range is used in scenario analysis.
-
Find the various compounding factors for N = 10 years and d = 5 percent.
-
Apple Inc. has established a unique reputation in the consumer electronics industry with its development of products such as the iPod, the iPhone, and the iPad. As of May 2010, Apple had surpassed...
-
Diplomatic Security Service provides Airport Transportation and Surveillance Service to Foreign Diplomats in Guyana. The company has two support departments - Information Systems and Equipment...
-
Q1: A disparity of bargaining power between the parties to a contract may result in unfair terms but a court is not likely to consider the contract unconscionable. Group of answer choices a. True b....
-
Life Tool Manufacturing has a system in place to recall products that prove to be dangerous at some time after manufacture and distribution. This represents which element of the due care theory?...
Study smarter with the SolutionInn App