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.

/*** * TestScores.java * Dean & Dean * * This implements an algorithm that averages test scores. import

In the above program, note how the following lines appear above the loop and also at the bottom of the loop:

  1. System.out.print(

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

1 Expert Approved Answer
Step: 1 Unlock

To modify the program as described we can introduce a dowhile loop instead of a while loop This way ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!