Problem

Using a Sentinel Value to Control a while Loop In this lab, you write a while loop tha...

Using a Sentinel Value to Control a while Loop

In this lab, you write a while loop that uses a sentinel value to control a loop in a Java program provided with the data files for this book. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. You designed this program for the Hollywood Movie Rating Guide in Chapter 5, Exercise 15, in Programming Logic and Design. Each theater patron enters a value from 0 to 4 indicating the number of stars that the patron awards to the Guide's featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie.

1. Open the source code file named MovieGuide.java using Notepad or the text editor of your choice.

2. Write the while loop using a sentinel value to control the loop, and also write the statements that make up the body of the loop.

3. Save this source code file in a directory of your choice, and thin make that directory your working directory.

4. Compile the source code file, movieGuide.java.

5. Execute the program. Input the following as star ratings:

0      3       4       4       1       1       2       -1

6. Record the average star rating for the movie.

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 5
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