Write a class Sentinel that reads integers until the user types -1, then prints:
Count: 4
Sum: 30
Average: 7.50
The sentinel -1 is not part of the numbers. If no number was entered before -1, print No numbers instead of the three lines.
THINK FIRST·CODE LATER
Problem
Write a class Sentinel that reads integers until the user types -1, then prints:
Count: 4
Sum: 30
Average: 7.50
The sentinel -1 is not part of the numbers. If no number was entered before -1, print No numbers instead of the three lines.
Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.
Model solution