2016/1/10 Example 1, console input number 2, console input corresponding number of results 3, the sum of the results and the maximum minimum value of the average

Source: Internet
Author: User

1 ImportJava.util.Scanner;2 3 4  Public classKongzhitai {5 6     7      Public Static voidMain (string[] args) {8         //TODO Auto-generated method stubs9         Ten         //first step output scan received number One         intnumber=0;//Defining Variables ASystem.out.println ("Please enter the number of people:"); -Scanner arr=NewScanner (system.in);//Scan -Number=arr.nextint ();//Receive the              -         //The second step is to assign the received number to the array length . -             //Output Scan -         Double[] t=New Double[number];//Note the number array length +System.out.println ("Please enter your score:"); -Scanner ar=NewScanner (system.in);//number of scan console inputs +              A         //The third step is to establish an index that receives input from the number of output arrays and at         Doublesum = 0;//Defining Variables -          for(inti=0;i<t.length;i++) {//to index the value entered -T[i]=arr.nextdouble ();//Array T[i] receives the scanned data -sum+=T[i]; -}SYSTEM.OUT.PRINTLN ("Total score:" +sum); -          in         //Fourth Step bubbling Algorithm > [0] is the minimum value <[0] is the maximum value -          for(intj=0;j<t.length;j++) {//number of rows to compare to              for(inti=0;i<t.length-1-j;i++) {//Number of comparisons (number of columns) +                                               //the more rows you compare, the fewer times you need to compare the number of accompanying numbers, and the less you need to-j the last number so you don't have to compare so-1 -                 if(t[i]>t[i+1]){ the                     Doublex=T[i]; *T[i]=t[i+1]; $t[i+1]=x;Panax Notoginseng                      -                 } the             } +}system.out.println ("The lowest score is:" +t[0]); ASystem.out.println ("Highest score is:" +t[t.length-1]); theSystem.out.println ("Average score is:" +sum/t.length); +     } -}

2016/1/10 Example 1, console input number 2, console input corresponding number of results 3, the sum of the results and the maximum minimum value of the 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.