Question
In method main , write the Java code to prompt the user to enter an unspecified number of integers and read these numbers in via
In method main, write the Java code to prompt the user to enter an unspecified number of integers and read these numbers in via a loop. When the user enters zero, the loop halts and the number of positive integers is output, the number of negative integers is output, the total of the numbers is output and the average of the numbers is output. The terminal zero is not included in the average. If the first number entered is zero, the program outputs a message that no numbers other than zero were entered.
Samples Run 1:
Enter integers separated by spaces (zero halts input): 1 2 1 3 0 Positives: 3 Negatives: 1 Total: 5
Average: 1
Samples Run 2:
Enter integers separated by spaces (zero halts input): 0 No numbers other than zero entered.
Samples Run 3:
Enter integers separated by spaces (zero halts input): 10 20 30 0 Positives: 1 Negatives: 2 Total: 40
Average: 13
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