Java applets practice performance assessment in accordance with the rules of storage arrays students

 

import java.util.Scanner;

public  class scoreForm {
     public  static  void main (String [] args) {
         // use Scanner to read the number of students 
        System.out.println ( "Please enter the number of students" );
        Scan Scanner = new new Scanner (System.in);
         int NUM = scan.nextInt ();
         // create an array to store student achievement 
        int [] arr = new new  int [NUM];
         // to elements in the array assignment 
        for ( int i 0 =; I <arr.length; I ++ ) {
            System.out.println ( "first" + (i + 1) + " student achievement is" );
            arr[i] = scan.nextInt();
        }
        // Get the highest score, i.e., the maximum array 
        int max = ARR [0 ];
         for ( int I = 0; I <arr.length; I ++ ) {
             IF (max < ARR [I]) {
                max = arr[i];
            }
        }
        System.out.println ( "highest score is" + max);
         // assess student achievement according to the rules
     for (int i = 0; i < arr.length; i++) {
      if (arr[i] >= max - 10) {
        lvl='A';
      } else if (arr[i] >= max - 20) {
        lvl='B';
      } else if (arr[i] >= max - 30) {
         lvl='C';
      } else {
        lvl='D';
       }
   System.out.println("第" + (i + 1) + "位学生等级是"+lvl);
    }
   } 

}
 

Guess you like

Origin www.cnblogs.com/xianghaoran/p/12219809.html