Keyboard input student achievement, will be divided into four sub-100 levels, excellent. Good. And. Less. Corresponding to the output level, there must be fault-tolerant processing

. 1  Import java.util.InputMismatchException;
 2  Import java.util.Scanner;
 . 3  
. 4  / * 
. 5            keyboard input student's score, divided into four levels to 100, and preferably less than good.... Corresponding to the output level, there must be fault-tolerant
 . 6   * / 
. 7  public  class Demo {
 . 8      public  static  void main (String [] args) {
 . 9          Scanner SC = new new Scanner (the System.in);
 10          the try {
 . 11              the while ( to true ) {
 12                  System.out.println ( "Please enter the result:" );
 13                  int score =sc.nextInt ();
 14                  IF (Score <0 || Score> 100 ) {
 15                      System.out.println ( "input results do not meet the requirements of the subject" );
 16                      Continue ;
 . 17                  }
 18 is                  IF (Score> = 90 Score && <100 ) {
 . 19                      System.out.println ( "excellent" );
 20 is                  } the else  IF (Score> = 80 && Score <90 ) {
 21 is                      System.out.println ( "good" );
 22 is                  } the else  IF ( score> = 60 && score <80){
23                     System.out.println ( "pass" );
 24                  } the else {
 25                      System.out.println ( "fail" );
 26 is                  }
 27              }
 28          } the catch (a InputMismatchException E) {
 29              System.out.println ( "input is not an integer " );
 30          }
 31      }
 32 }

Guess you like

Origin www.cnblogs.com/wangjixue/p/12121478.html