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.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.