Second jave jobs

1. Analyzing leap year

Import . Classes in java.util * ;
 public  class One {
      public  static  void main (String [] args) { 
         Scanner INPUT = new new Scanner (the System.in); 
         System.out.println ( "Please enter a year:" );
          Long year = input.nextLong ();                               
          IF (! year. 4 == 0 && year% 100% 400% year || = 0 == 0 ) { 
                System.out.println (year + "is a leap year!" ); 
         } the else { 
                System.out.println (year + "is not a leap year" ); 
         }
   }

}

 

 2. Enter a 4-digit card number, if one hundred number is a multiple of three, then the output is fortunate members, otherwise it is not output.

Import . Classes in java.util * ;
 public  class One {
      public  static  void main (String [] args) { 
         Scanner INPUT = new new Scanner (the System.in); 
         System.out.println ( "Please enter the card number:" );
          Long hykh = input.nextLong ();   
         IF (hykh> && hykh 999 <9999 ) {
             IF (hykh 1000% / 100%. 3 == 0 ) { 
                System.out.println ( "Ning oct transport member" ); 
            } the else { 
                the System.out .println ( "eight is your lucky member" );
            } 
        } The else { 
            System.out.println ( "Please enter the card number 4" ); 
        } 
     } 
}

 

 

3. The value of the function is known, the value of the input x, output y of the corresponding.
X. 3 + (x> 0)
y = 0 (x = 0)
X2 -1 (x <0)

import java.util.*;
public class One {
     public static void main(String[] args) {
         Scanner input = new Scanner(System.in);
         System.out.println("x:");
         int x = input.nextInt();   
         if (x>0) {
            System.out.println("y="+(x+3));
        }else if (x<0) {
            System.out.println("y="+(x*2-1));
        }else {
            System.out.println("y=0");
        }

     }
}

 

 

 4. Enter Number determined whether the three triangles can be constructed

import java.util.*;
public class One {
     public static void main(String[] args) {
         Scanner input = new Scanner(System.in);
         System.out.println("输入三位数");
         int x = input.nextInt();  
         int y = input.nextInt();  
         int z = input.nextInt(); 
         if (x+y>z&&x+z>y&&y+z>x) {
            System.out.println("可以构成三角形");
        }else {
            System.out.println("不!");
        }
            
    

 

Guess you like

Origin www.cnblogs.com/rozenscarlet/p/12549779.html