java fourth week of work

1. programming, the value of the input variable x, if it is 1, output x = 1, if it is 5, the output x = 5, if it is 10, x = 10 outputs, in addition to the above several values ​​are output x = none.

INPUT = new new Scanner Scanner (the System.in); 
		System.out.println ( "Please enter the value of x:"); 
		int x = input.nextInt (); 
		IF (x == ==. 1. 5 || x || 10 == x) { 
			System.out.println ( "value of x is:" + x); 
		} the else { 
			System.out.println ( "value of x is: none"); 
		}

  

 

 

 2. switch structure to achieve the first question

INPUT = new new Scanner Scanner (the System.in); 
		System.out.println ( "Please enter the value of x:"); 
		int x = input.nextInt (); 
		Switch (x) { 
		Case. 1: 
			System.out.println ( "is the value of x: = x. 1"); 
			BREAK; 
		Case. 5: 
			System.out.println ( "value of x is: x =. 5"); 
			BREAK; 
		Case 10: 
			System.out.println ( "value of x is: x = 10 "); 
			BREAK; 
		default: 
			System.out.println (" value of x is: none "); 
		}

  

 

 

Determining whether a number is 3. 5 and 6 can be simultaneously divisible (5 and 6 can be divisible print), or can only be divisible by 5 (5 be divisible print)
    , or can only be divisible by 6, (6 can be divisible print) can not be divisible by 5 or 6, (printing can not be divisible by 5 or 6)

INPUT = new new Scanner Scanner (the System.in); 
		System.out.println ( "Enter a number:"); 
		int X = input.nextInt (); 
		IF (X == 0 &&%. 5%. 6 X == 0) { 
			System.out.println (x + "be divisible by 6 and 5"); 
		} the else IF (5% X == 0) { 
			System.out.println (x + "be divisible by 5"); 
		} the else IF (X% 0 == 6) { 
			System.out.println (+ X "can be divisible by 6"); 
		} the else { 
			System.out.println (+ X "can not be divisible by 6 and 5"); 
		}

  

 

 

4. Enter a score of 0 to 100, if not between 0 to 100, the print score is invalid,
   printing A (90-100), B (80-89 ) according to grade scores, C, D, E (knowledge: Condition statements if else if)

INPUT = new new Scanner Scanner (the System.in); 
		System.out.println ( "Please enter a number between 100 ~. 1:"); 
		int X = input.nextInt (); 
		IF (X <0 || X> 100) { 
			System.out.println ( "! enter your score is not lawful"); 
		} the else { 
	    IF (the X-> = 90 && the X-<= 100) { 
	    	System.out.println ( "get your grades for: a" );	 
		} the else IF (X> = 80 && X <= 89) { 
			System.out.println ( "your performance level is obtained: B"); 
		} the else IF (X> = 70 && X <= 79) { 
			the System.out. println ( "your performance level is obtained: C"); 
		} the else IF (X> = 60 && X <= 69) { 
			System.out.println ( "your performance level is obtained: D"); 
		} the else IF (X > = 50 && the X-<= 59) { 
			System.out.println ( "get your grades for: E");
		the else {} 
			System.out.println ( "Your performance is unacceptable!"); 
		} 
		}

  

 

 

5. Enter three integers x, y, z, please small to large number of these three outputs (knowledge: conditional statements)

INPUT = new new Scanner Scanner (the System.in); 
		System.out.println ( "Enter first integer X:"); 
		int X = input.nextInt (); 
		System.out.println ( "Please enter the second integer Y: "); 
		int input.nextInt Y = (); 
		System.out.println (" Please enter the third integer Z: "); 
		int input.nextInt Z = (); 
		int TEMP = 0; 
		IF (X > Y) { 
			TEMP = Y; 
			Y = X; 
			X = TEMP; 
		} 
		IF (X> Z) { 
			TEMP = Z; 
			Z = X; 
			X = TEMP; 
		} 
		IF (Y> Z) { 
			TEMP = Z; 
			Z = Y; 
			Y = TEMP; 
		} 
		System.out.println ( "three ascending order of the number of" + x + "," + y + "," + z + "");

  

 

Guess you like

Origin www.cnblogs.com/lilbetter03/p/12573672.html