zoukankan      html  css  js  c++  java
  • 第三次java作业

    1.

    package set;
    import java.util.Scanner;
    public class set {
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Scanner input = new Scanner(System.in);
            System.out.println("请输入年份:");
            long year = input.nextLong();
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                System.out.println(year + "是闰年!");
            } else {
                System.out.println(year + "不是闰年");
            }
        }
    
    }

     2.

    package set;
    import java.util.Scanner;
    public class set {
        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%1000/100)%3==0){
                System.out.println("恭喜您是幸运会员");
            }else if(a<1000){
                System.out.println("不是会员号");
            }else{
                System.out.println("抱歉您不是幸运会员");
            }
       }        
    }

     3.

    package set;
    import java.util.Scanner;
    public class set {
        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>0){
                System.out.println("y的值为"+(x+3)) ;
            }else if(x==0){
                System.out.println("y的值为"+(0));
            }else if(x<0){
                System.out.println("y的值为"+(x*x-1));
            }
       }        
    }

     4.

    package set;
    
    import java.util.Scanner;
    
    public class set {
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Scanner input = new Scanner(System.in);
            System.out.print("请输入第一个数:");
            int a = input.nextInt();
            System.out.println();
            System.out.print("请输入第二个数:");
            int b = input.nextInt();
            System.out.println();
            System.out.print("请输入第三个数:");
            int c = input.nextInt();
            System.out.println();
            if (a + b > c || b + c > b || a + c > a) {
                System.out.println(a + "" + b + "" + c + "" + "可以构成三角形");
            } else {
                System.out.println(a + "" + b + "" + c + "" + "不可以构成三角形");
            }
    
        }
    
    }

  • 相关阅读:
    超神头文件
    世界上还有比二分更容易错的算法吗?
    【POJ 1734】Sightseeing trip
    P1303 A*B Problem
    P1601 A+B Problem(高精)
    P1051 谁拿了最多奖学金
    【P1025】数的划分
    P1005 矩阵取数游戏
    P1006 传纸条
    邮票问题
  • 原文地址:https://www.cnblogs.com/qsf1975747------/p/12550416.html
Copyright © 2011-2022 走看看