1 ImportJava.util.Scanner;2 Public classArithmetic {3 Public Static voidMain (string[] args) {4 Calcarr ();5 }6 Public Static voidCalcarr ()7 {8 int[] arr =New int[10];9 intMax = 0;Ten intMin = 0; One intTotal = 0; A intAVG = 0; -Scanner scan =NewScanner (system.in); - for(inti = 0; i < arr.length; i++) { theString s = "a"; - while(!s.matches ("^[0-9]+$")) - { - //System.out.printf ("Please enter number%d%n", i+1); +System.out.println (String.Format ("Number of input%d", i+1)); -s =Scan.next (); + } AArr[i] =Integer.parseint (s); at if(Max <Arr[i]) -Max =Arr[i]; - if(Min >Arr[i]) -Min =Arr[i]; -Total + =Arr[i]; - } inSYSTEM.OUT.PRINTLN ("Minimum value:" +min); -SYSTEM.OUT.PRINTLN ("Maximum value:" +max); toSystem.out.println ("Average:" +total/arr.length); + } -}
Defines a group of 10 integers that can be used to hold 10 integers entered by the user through the console and to calculate their maximum minimum average.