The following code is what I was able to create but now I'm confused on what to do next.
Write a program that reads a sequence of integer inputs and prints
- The cumulative total of the numbers
- The smallest of the inputted numbers
- The largest of the inputted numbers
- The number of even inputs
- The number of odd inputs
- The average of the numbers (you will need to track another piece of information for this)
The program should set up the input (Scanner) and variables first, then use a while loop that asks the user for input and keeps track of the data needed. A way must be specified for the user to stop inputs, perhaps by entering Q or q. When the loops ends, the program should print the results for the questions. The cumulative total of the numbers so far should be printed after each number that the user inputs. The smallest, largest, number of evens, number of odds and average need only be printed after the user has finished entering numbers.You will need if statements and modulus to complete this task. All numbers should be integers for this program. When you are finished, please turn in your commented code on Blackboard. Please be sure your name is commented at the top of your code.
//Asks user of a number
System.out.print("Enter an integer: ");
int num = 0;
int num1;
int num2;
int num3;
int num4;
int num5;
while (in.hasNextInt())
{
num = in.nextInt();
System.out.print("Enter next integer or Q to quit ");
}
//Gets total of numbers
//Gets smallest number
//Gets largest number
//Number of even inputs
//Number of odd inputs
//Gets average of numbers