java java is calculated based on the use of a classmate score highest lowest average

java.util.Arrays Import; 

// classmates all subjects as 100,99,88,22,40,98,95  
 // highest score lowest score of the students obtained the average 
public  class copyScore {
     public  static  void main ( String [] args) {
         // initialization subjects score 
        Integer [] scores = new new Integer [] { 100 , 99 , 88 , 22 is , 40 , 98 , 95 }; 
        
        // here simplified wording: Integer scores [] 100,99,88,22,40,98,95 = {}; 
        
        // first summing 
        Integer SUM = 0 ;
         for ( int= I 0 ; I <scores.length; I ++ ) {
             // the accumulated value out   
            SUM + = Scores [I];   
        } 
        the System. OUT .println ( " Total: " + SUM); 
        
        // Sort: 
         // Arrays.sort sorting, ascending, descending not, they can reverse the output 
        Arrays.sort (Scores); // after sorting, the result back to the original array 
        String = result of Arrays.toString (Scores);
         // after sorted in ascending order the 
        System. oUT .println (the Result); 
        
        // highest score 
        . System oUT .println ( "Students highest score: " + Scores [scores.length- 1 ]);
         // lowest score 
        System. OUT .println ( " Minimum students are divided into: " + Scores [ 0 ]);
         // Average 
        System. OUT .println ( " students average: " + (SUM / scores.length)); 
    } 
    
}

 

Guess you like

Origin www.cnblogs.com/key2/p/11461237.html