Java Jobs (i)

Source: Internet
Author: User

Topic:

  

Diving competition, 8 judges scored. The athlete's score is 8 grades to remove a top score, remove a minimum score, the remaining 6 points of the average score is the final score. Use the scoring function for arrays. Please find the highest scoring judges and the lowest judges.

  

Analytical:

1  PackageHomework1;2 3 ImportJava.io.BufferedReader;4 Importjava.io.IOException;5 ImportJava.io.InputStreamReader;6 7 /*8 * Diving competition, 8 judges score. The athlete's score is 8 grades minus a top score, minus a minimum score,9 * The average of the remaining 6 points is the final score. Use the scoring function for arrays. Ten * Please find the highest scoring judges and the lowest judges.  One  * */ A  Public classHomework1 { -  -     /** the      * @paramargs -      */ -      Public Static voidMain (string[] args) { -         //TODO auto-generated Method Stub +Judge judge=NewJudge (); - System.out.println (Judge.lastfen ()); +     } A  at } -  - classJudge - { -     //defines an array of 8 small trees that can be stored -     floatFens[] =NULL; in     intSize = 8; -     //constructor Function to      PublicJudge () +     { -Fens =New float[size]; the         //Initialize *InputStreamReader ISR =NewInputStreamReader (system.in); $BufferedReader br =NewBufferedReader (ISR);Panax Notoginseng          -              the             Try { +                  for(inti=0;i<fens.length;i++) A                 { theSystem.out.println ("Please enter" + (i+1) + "Referee's score"); +Fens[i] =float.parsefloat (Br.readline ()); -                 }  $}Catch(Exception e) { $ e.printstacktrace (); -}finally { -                 Try { the br.close (); -}Catch(IOException e) {Wuyi                     //TODO auto-generated Catch block the e.printstacktrace (); -                 } Wu             } -              About          $     } -     //get the athlete's final score -      Public  floatLastfen () -     { A         floatAllfen=0; +          the         intminindex= This. Getlowfenindex (); -         intmaxindex= This. Gethighfenindex (); $          the          for(inti=0;i<fens.length;i++) the         { the             if(i!=minindex&&i!=Maxindex) the             { -allfen+=Fens[i]; in             } the         } the         returnallfen/(fens.length-2); About          the         //3. Get an average score the     } the     //2. Remove the highest score +      Public intGethighfenindex () -     { the         //Selection MethodBayi         //think the first one is the lowest score the         floatHighfen = Fens[0]; the         intMaxindex = 0; -          for(intI= 1;i<fens.length;i++) -         { the             if(highfen>Fens[i]) the             { the                 //Modify Minimum Copy thehighfen=Fens[i]; -Maxindex =i; the             } the         } the         returnMaxindex;94     } the     //1. Remove the minimum score the      Public intGetlowfenindex () the     {98         //Selection Method About         //think the first one is the lowest score -         floatMinfen = Fens[0];101         intMinindex = 0;102          for(intI= 1;i<fens.length;i++)103         {104             if(minfen>Fens[i]) the             {106                 //Modify Minimum Copy107minfen=Fens[i];108Minindex =i;109             } the         }111         returnMinindex; the     }113}

Java Jobs (i)

Related Article

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.