Package Shuzu;import Java.util.scanner;public class Shuzu_pjs {public static void main (string[] args) {//user input a series of numbers and then find out which The number Scanner in = new Scanner (system.in), and the output number is greater than the average. System.out.println ("How many values do you want to enter?") Please enter: ");//Calculate the average, need to have: 1. Record each number of inputs n; number of inputs and sum; number of input values cnt;int cnt = In.nextint ();//Calculate average, define sum as floating-point double sum = 0; System.out.println ("Enter your value:");//create an array called num, and enter the values for each entry. int[] num = new int[cnt];//iterates over the array num, assigns each number entered to num[i]for (int i=0;i<cnt;i++) {Num[i] = In.nextint ();//By the way, the sum of the input values is computed Sum + num[i];} System.out.println ("The average of these numbers is:" +sum/cnt);//iterate over the array num, which will be greater than the sum of the number output for (int i=0; i<cnt; i++) {if (num[i]>sum/cnt) { System.out.println (num[i]+ "");}}}
0 basic Java language Fifth week array--averaging number examples