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

    1.输入一个年份,判断是不是闰年(能被4整除但不能被100整除,或者能被400整除)

    package com.a01;

     

    import java.util.*;

     

    public class hellowold {

        public static void main(String[] args) {

           Scanner input = new Scanner(System.in);

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

           int a = input.nextInt();

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

               System.out.println(a + "是闰年");

           } else {

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

           }

        }

    }

    2.输入一个4位会员卡号,如果百位数字是3的倍数,就输出是幸运会员,否则就输出不是.

    package com.a01;

     

    import java.util.*;

     

    public class hellowold {

        public static void main(String[] args) {

           Scanner input = new Scanner(System.in);

           System.out.println("输入一个四位卡号");

           int a = input.nextInt();

           if (a / 100 % 10 % 3 == 0 && a / 100 % 10 != 0) {

               System.out.println(a + "是幸运会员");

           } else {

               System.out.println(a + "不是");

           }

        }

    }

    3.已知函数,输入x的值,输出对应的y的值. x + 3 ( x > 0 ) y = 0 ( x = 0 ) x2 –1 ( x < 0 )

    package com.a01;

     

    import java.util.*;

     

    public class hellowold {

        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);

           } else {

               System.out.println("y=" + (x * 2 - 1));

           }

        }

    }

    4.输入三个数,判断能否构成三角形(任意两边之和大于第三边) 

    package com.a01;

     

    import java.util.*;

     

    public class hellowold {

        public static void main(String[] args) {

           Scanner input = new Scanner(System.in);

           System.out.println("取3条边预构成一个三角形");

           int a = input.nextInt();

           int b = input.nextInt();

           int c = input.nextInt();

           if (a+b>c&&a+c>b&&b+c>a) {

               System.out.println("这三条边能构成一个三角形");

           } else {

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

           }

        }

    }

  • 相关阅读:
    win10安装jmeter配置环境路径
    genymotion在mac上的安装
    jmeter的启动
    win10的cmd输入javac的问题
    01 | 你真的懂测试吗?从“用户登录”测试谈起 茹炳晟
    冒烟测试
    软件测试基础知识
    红队指南--第3章 列举
    REDTEAM 指南---第四章 外部侦察
    Red Team 指南-第1章 红队和红队概述
  • 原文地址:https://www.cnblogs.com/hyonf/p/12561929.html
Copyright © 2011-2022 走看看