第4次作业

上机作业

1. package ljk;

 

import java.util.Scanner;

 

public class ljlj {

 private void scanner() {

    // TODO Auto-generated method stub

 

}

    /**

     * @param args

     */

    public static void main(String[] args) {

        // TODO Auto-generated method stub

     Scanner input=new Scanner(System.in);

        int a=input.nextInt();

    if ((a%4==0&&a%100!=0)||(a%400==0)){

    System.out.println("是闰年");}

    else{

    System.out.println("不是闰年");}

   

    }

 

}

 

 

 

2. package ljk;

 

import java.util.Random;

import java.util.RandomAccess;

import java.util.Scanner;

public class ljlj {

 private void scanner() {

    // TODO Auto-generated method stub

 

}

    /**

     * @param args

     */

    public static void main(String[] args) {

        // TODO Auto-generated method stub

     Scanner input=new Scanner(System.in);

     System.out.println("输入卡号");

        int y=input.nextInt();

        Random r=new Random();

        int a=r.nextInt(10);

    if ((y/10%10)==a){

    System.out.println("是会员");}

    else{

    System.out.println("不是会员");}

   

    }

 

}

 

 

 

3. package ljk;

 

 

import java.util.Scanner;

public class ljlj {

 private void scanner() {

    // TODO Auto-generated method stub

 

}

    /**

     * @param args

     */

    public static void main(String[] args) {

        // TODO Auto-generated method stub

     Scanner input=new Scanner(System.in);

        int x=input.nextInt();

    if (x>0){

    System.out.println(x+3);}

    else if(x==0){

    System.out.println(x);}

    else if(x<0){

    System.out.println(x*2-1);}

    }

 

}

 

 

 

 

4. package ljk;

 

 

import java.util.Scanner;

public class ljlj {

 private void scanner() {

    // TODO Auto-generated method stub

 

}

    /**

     * @param args

     */

    public static void main(String[] args) {

        // TODO Auto-generated method stub

     Scanner input=new Scanner(System.in);

        int a=input.nextInt();

        int b=input.nextInt();

        int c=input.nextInt();

    if ((a+b>c)&&(a-b<c)||(a+c>b)&&(a-c<b)||(b+c>a)&&(b-c<a)){

    System.out.println("可以组成三角形");

   }else {

    System.out.println("不能组成三角形");}

 

 

   

    }

    }

 

 

课后作业

1.

package Class1;

 

 

import java.util.Scanner;

 

public class Class5 {

 

   /**

    * @param args

    */

   public static void main(String[] args) {

      // TODO Auto-generated method stub

      Scanner input=new Scanner(System.in);

      System.out.println("请输入年份");

      int year=input.nextInt();

      System.out.println("请输入月份");

      int month=input.nextInt();

      if (year%4==0&&year%100!=0||year%400==0) {

          if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){

                month=31;

             }else if(month==4||month==6|month==9||month==11){

                month=30;

             }else if(month==2){

                month=29;

             }

          }else{

          if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){

                month=31;

             }else if(month==4||month==6|month==9||month==11){

                month=30;

             }else if(month==2){

                month=28;

             }

          System.out.println("该年份的月份为"+month);

          }    

   }

 

}

 

 2.

package Class1;

 

import java.util.Scanner;

 

public class Class6 {

 

   /**

    * @param args

    */

   public static void main(String[] args) {

      // TODO Auto-generated method stub

      Scanner input=new Scanner(System.in);

      System.out.println("请输入成绩");

      int a=input.nextInt();

      switch (a/10) {

      case 6:

          System.out.println("您的成绩等级为D");

          break;

      case 7:

          System.out.println("您的成绩等级为C");

          break;

      case 8:

          System.out.println("您的成绩等级为B");

          break;

      case 9:

      case 10:

          System.out.println("您的成绩等级为A");

          break;

      default:

          System.out.println("您的成绩等级为E");

          break;}

      }

 

   }

 

 3.

package Class1;

 

import java.util.Scanner;

 

public class Class7 {

 

   /**

    * @param args

    */

   public static void main(String[] args) {

      // TODO Auto-generated method stub

      Scanner input=new Scanner(System.in);

      System.out.println("请输入一个数字");

      int a=input.nextInt();

      if(a%2==0){

          System.out.println("该数为偶数");

      }else{

          System.out.println("该数为奇数");

      }

 

   }

 

}

 

 4.

package Class1;

 

import java.util.Scanner;

 

public class Class8 {

 

   /**

    * @param args

    */

   public static void main(String[] args) {

      // TODO Auto-generated method stub

      Scanner input=new Scanner(System.in);

      System.out.println("请输入一个数值X");

      int x=input.nextInt();

      if(x==1){

          System.out.println("x=1");

      }else if(x==5){

          System.out.println("x=5");

      }else if(x==10){

          System.out.println("x=10");

      }else{

          System.out.println("x=none");

      }

 

   }

 

}

 

 5.

package Class1;

 

import java.util.Scanner;

 

public class Class9 {

 

   /**

    * @param args

    */

   public static void main(String[] args) {

      // TODO Auto-generated method stub

      Scanner input=new Scanner(System.in);

      System.out.println("请输入一个数值X");

      int x=input.nextInt();

      if(x%5==0&&x%6==0){

          System.out.println("能被5和6整除");

      }else if(x%5==0){

          System.out.println("只能被5整除");

      }else if(x%6==0){

          System.out.println("只能被6整除");

      }else if(x%5!=0||x%6==0){

          System.out.println("不能被5或6整除");

      }

     

   }

 

}

 

posted on 2021-03-26 18:33  觊·觎  阅读(48)  评论(0编辑  收藏  举报

导航