Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Write a static method that takes a scanner object as a parameter and uses a sentinel loop to repeatedly prompt the user for numbers.
Java
Write a static method that takes a scanner object as a parameter and uses a sentinel loop to repeatedly prompt the user for numbers. Once the user types any number less than zero, the method should display the average of all nonnegative numbers typed. Display the average as a double. Here is a sample dialogue with the user: Type a number: 7 Type a number: 4 Type a number: 16 Type a number: 4 Average was 9.0 If the first number that the user types is negative, do not print an average: Type a number: 2 Write a program to call and test your function 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