In: Computer Science
JAVA) I need to get 10 integer numbers from the user. Then I need to find sum of odd numbers, sum of even numbers, the lowest number of all numbers, the highest number of all numbers, and the average of all numbers( use double, with the two digit decimal)
process;
loopCount = 1
While LoopCount <= 10
Read number from the keyboard
If odd, add to the total of all odd numbers
If even, add to the total of all even numbers
Add to the total of ALL numbers
Determine the smallest and largest number
Increment loopCount
End Loop Identify and display all three totals and range of numbers
Compute and display the average
import java.util.Scanner; public class NumberStats { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter 10 numbers: "); int loopCount = 1, number, evenTotal = 0, oddTotal = 0, total = 0, min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; while (loopCount <= 10) { number = in.nextInt(); if (number % 2 == 0) evenTotal += number; else oddTotal += number; total += number; if (number > max) max = number; if (number < min) min = number; loopCount++; } System.out.println("Even total is " + evenTotal); System.out.println("Odd total is " + oddTotal); System.out.println("Total is " + total); System.out.println("Min number is " + min); System.out.println("Max number is " + max); System.out.println("Average is " + (total/10.0)); } }