Java serialized 21-switch practice

A, switch exercises

 

public  class d21_ { 

  public  static  void main (String [] args) { 

    java.util.Scanner S = new new java.util.Scanner (System.in); 

    System.out.print ( "Please enter the day of the week today:" ); 

    dayOfWeek String = s.next (); 

    Switch (dayOfWeek) { 

    Case "Monday" : 

      System.out.println ( . 1 ); 

      BREAK ; 

    Case "Tuesday" : 

      System.out.println ( 2 ); 

      BREAK ; 

    default : 

      the System .out.println ( "I'm sorry the data you entered illegally.");

     

    }

  }

}

Note: switch (int / String)

We, for example, where the char type is passed, but in fact it is 'B', that is, 66

 

char A = 'B' ; 

    Switch (A) { 

    Case 'B' : 

      System.out.println ( "Yes" ); 

      BREAK ; 

    default : 

      System.out.println ( "wrong" );          

    } 

   

    Switch (A) { 

    Case 66 : 

      System.out.println ( "turn right" ); 

      BREAK ; 

    default : 

      System.out.println ( "wrong turn" ); 

    }

 

Second, we determine the level of student achievement

 

    @ Demand: 

    Double A1 = 95.5 ; 

    int B1 = ( int ) (A1 / 10 ); 

    Switch (B1) { 

    Case 10: Case . 9  : 

      System.out.println ( "This is the level A" ); 

      BREAK ; 

    Case . 8 : Case . 7: Case . 6 : 

      System.out.println ( "this is the level B" ); 

    default : 

      System.out.println ( "this is the level C" ); 

    } 

  } 

}

Third, the source code:

d21_switch_exercise.java

Address: https: //github.com/ruigege66/Java/blob/master/d21_switch_exercise.java

2.CSDN: https: //blog.csdn.net/weixin_44630050 (Xi Jun Jun Moods do not know - Rui)

3. Park blog: https: //www.cnblogs.com/ruigege0000/

4. Welcomes the focus on micro-channel public number: Fourier transform, backstage reply "gifts" to get big data learning materials

Guess you like

Origin www.cnblogs.com/ruigege0000/p/11415868.html