Question
Write a Java program that contains a while loop that can be controlled using a sentinel value. Write your loop so that only positive, even
Write a Java program that contains a while loop that can be controlled using a sentinel value. Write your loop so that only positive, even values are summed up and the resulting average of those numbers is output to the console once the sentinel value of 672is entered. After the loop exits, provide an output that includes descriptive text, the calculated sum, and the calculated average which should be limited to four decimal places.The sentinel value should not be included in any calculations. For instance, the input of 4, 2, -5,-7, 8, 3, 7, 672should provide a sum of (4+2+8) = 14 and an average of 14/3 ~= 4.666
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started