Problem

Consider the BowlingScores program below./************************************************...

Consider the BowlingScores program below.

/************************************************************** BowlingScores.java* Dean&Dean** This implements a bowling scores algorithm.*************************************************************/import java.util.Scanner;public class BowlingScores{ public static void main(String[] args){ Scanner stdIn = new Scanner(System.in); int score; int totalScore = 0; int count = 0; double average; System.out.print(“Enter score (−1 to quit): “); score = stdIn.nextInt(); while (score >= 0){  totalScore += score;  count++;  System.out.print(“Enter score (−1 to quit): “);  score = stdIn.nextInt(); } average = (double) totalScore / count; System.out.println(“Average score is “ + average); } // end main}// end BowlingScores class

Modify this program to avoid division by zero. Initialize a

boolean
variable called
more
with
true
, and use it as the
while
loop condition. Eliminate the prompt and input before the loop and move the prompt and input inside the loop to the top of the loop. Use an “if, else” structure in the loop to
set more to false
and bypass the normal calculation if the input is negative.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT