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

    package bwk2;
    import java.util.Scanner;
    public class Zye {
    
        public static void main(String[] args) {
            // 1.输入一个年份,判断是不是闰年(可以被4整除但不能被100整除,或者能被400整除
             System.out.println("请输入一个年份:");
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                if ((a % 4 == 0 && a % 100 != 0) || (a % 400 == 0)) {
                    System.out.println(a+"年是闰年");
                }else {
                    System.out.println(a+"年不是闰年");
                }
        }
    
    }

                                         

    package bwk2;
    import java.util.Scanner;
    public class Zye {
    
        public static void main(String[] args) {
            // 2.输入一个4位会员卡号 如果百位数字是3的倍数 输出幸运会员,否则就不是.
            System.out.print("请输入会员卡号:");
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            if (a >= 1000 && a <=9999) {
                if(a / 100 % 10 % 3 == 0) {
                    System.out.println(a+"是幸运会员");
                }else {System.out.println(a+"不是幸运会员");}
            }else {System.out.println("您的输入有误");}
        }
    
    }

    package bwk2;
    import java.util.Scanner;
    public class Zye {
    
        public static void main(String[] args) {
            // 已知函数 x 输出y x>0 (x+3) x=0 y=0 x<0 x*2-1
             Scanner sc = new Scanner(System.in);
                System.out.print("请输入x的值:");
                int x = sc.nextInt();
                int y;
                if(x > 0) {
                    y = x + 3;
                    System.out.println("y值为:"+y);
                }if(x < 0) {
                    y = x*2 - 1;
                    System.out.println("y值为:"+y);
                }if(x == 0){
                    y = 0;
                    System.out.println("y值为:"+y);
                }
        }
    
    }
     

    package bwk2;
    import java.util.Scanner;
    public class Zye {
    
        public static void main(String[] args) {
            //4. 输入三个数 构成三角形
             Scanner sc = new Scanner(System.in);
                System.out.print("请输入第一个数:");
                int a = sc.nextInt();
                System.out.print(" 请输入第二个数:");
                int b = sc.nextInt();
                System.out.print(" 请输入第三个数:");
                int c = sc.nextInt();
                if((a + b) >= c && (a + c) >= b && (b + c) >= a){
                    System.out.println("可构成三角形");
                }else {
                    System.out.println("不可以构成三角形");}
                }    
    
    }

  • 相关阅读:
    iPhone电话与短信相关代码小结
    时间都去哪儿了?开源一个统计iPhone上App运行时间和打开次数的小工具【iOS8已失效】
    分享一个仿网易新闻客户端iPhone版的标签式导航ViewController
    iOS推送小结(证书的生成、客户端的开发、服务端的开发)
    Argy1risMatrix1
    2019河南模考题
    撮箕2020-3-8
    数学符号md
    2014全国甲&2015福建-几何题
    零点
  • 原文地址:https://www.cnblogs.com/bwk521/p/12561235.html
Copyright © 2011-2022 走看看