Using a Sentinel Value to Control a while Loop in Java Summary In this lab, you write a while loop that uses a sentinel value to control a loop in a Java program that has been provided. 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. Each theater patron enters a value from 0 to 4 indicating the number of stars 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. Instructions Ensure the file named MovieGuide.java is open. Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop to calculate the average star rating. Execute the program by clicking Run. Input the following: 0, 3, 4, 4, 1, 1, 2, -1 Check that the average output is correct. Grading When you have completed your program, click the Submit button to record your score
Using a Sentinel Value to Control a while Loop in Java
Summary
In this lab, you write a while loop that uses a sentinel value to control a loop in a Java
The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars 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.
Instructions
-
Ensure the file named MovieGuide.java is open.
-
Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop to calculate the average star rating.
- Execute the program by clicking Run.
-
Input the following: 0, 3, 4, 4, 1, 1, 2, -1
-
Check that the average output is correct.
Grading
When you have completed your program, click the Submit button to record your score.

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









