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: 50% (2 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
-
Three lottery tickets for first, second, and third prizes are drawn from a group of 40 tickets. Find the number of sample points in S for awarding the 3 prizes if each contestant holds only 1 ticket.
-
Compressed air at \(p=20\) atm enters a \(20-\mathrm{mm}\) diameter tube at \(T_{m, i}=20^{\circ} \mathrm{C}\) and a mass flow rate of \(\dot{m}=6 \times 10^{-4} \mathrm{~kg} / \mathrm{s}\). The air...
-
Fresh Wholesale buys peaches from farmers and sells them to canneries. During May 2012, Fresh's inventory records showed the following: Fresh Wholesale uses the periodic inventory method to account...
-
Briefly describe the forensic psychology career field Explain what drew you to this field (forensic psychology) Examine the impact of past, current, and developing technology in your field (forensic...
-
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...
-
Suppose there are two marketed assets, each with price 1 and payoffs $y_{1}$ and $y_{2}$, respectively, with $\bar{y}_{1}=1.4$ and $\bar{y}_{2}=0.8$. Each has a variance of 0.04 , and they are...
-
How can a lockdown result in stagflation? A lockdown can have three different effects: a. The first happens when demand during the lockdown decreases so that actual output, \(Y_{t}\), falls exactly...
-
The dean of student activities wants to know students reaction to the new student center. Of the 500 students queried, 350 report that they like the new building. Estimate the proportion of the...
-
The daily catch of a small tuna-fishing fleet averages 130 t. The fleets logbook shows that the weight of the catch varies from day to day and this variation is measured by the standard deviation of...
-
Problems 914 refer to Figures AD. Set up definite integrals in Problems 912 that represent the indicated shaded area. Shaded area in Figure C. a f(x) h(x) a y = f(x) (A) b (C) b y = h(x) X X a F(x)...
-
You run an Islamic financing division and have been approached by a customer for a 40,000 Bahrain dinar ijarah thumma al bai financing deal. The customer wishes to pay a maximum of 1,000 Bahrain...
-
What are the reasons underlying the popularity of online documentation?
-
Which should drive action planning more, strengths or weaknesses? That is, is it more important to build on your strengths or to reduce your weaknesses? Explain.
-
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...
-
According to the following OUBuild Script find the output once we click on the green flag? when clicked set to 1 set to 12 repeat until repeat until j i say for 2 secs set to i/2 change by 1
-
3. Construct a test set that is adequate with respect to LCSAJ coverage criterion for the following program segment. (40 points) 1 2 public static boolean has At Least 3 Letters (String new Password)...
-
3D Printing-(construction) Answer questions below and describe Detailed description of Technology (3d printing) Possible Integration of the Technology with the BIM Technology(3d printing) Benefits...
Study smarter with the SolutionInn App