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
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.
/*** * 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
Step by Step Solution
3.44 Rating (163 Votes )
There are 3 Steps involved in it
To modify the program as described we can introduce a dowhile loop instead of a while loop This way ... View full answer
Get step-by-step solutions from verified subject matter experts

