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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!