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