Question: Write a Java program that uses a loop to read in a series of integers of unknown length; the program should continue to read in
Write a Java program that uses a loop to read in a series of integers of unknown length; the program should continue to read in integer values (positive and negative), one at a time, until the user enters a zero. After the loop ends (meaning that the user has entered 0), the program should print out four values: the number of positive (non-zero) integers that were entered, the number of negative (non-zero) integers that were entered, the sum of the non-zero integer values that were entered, and the average of the (non-zero) values that were entered (as a floating-point value) . Sample Execution (program output is shown in italics, and user input is shown in boldface): Please enter an integer (0 to quit):-3 Please enter an integer (0 to quit): 15 Please enter an integer (0 to quit): 11 Please enter an integer (0 to quit):-9 Please enter an integer (0 to quit): 2 Please enter an integer (O to quit): 0 Positive integers entered: 3 Negative integers entered: 2 Sum: 16 Average: 3.2 Don't worry about the precision (number of decimal places) for the average
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
