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

    package com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text2 {
        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 com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text2 {
        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 com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text2 {
        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 com.xuexiao;
    
    import java.util.Scanner;
    
    public class Text2 {
        public static void main(String[] args) {
            //输入三个数 构成三角形;
            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("不可以构成三角形");}
            }
            
            
        }

  • 相关阅读:
    [工作中的设计模式]中介模式模式Mediator
    [工作中的设计模式]责任链模式chain
    [工作中的设计模式]迭代子模式Iterator
    [工作中的设计模式]组合模式compnent
    TI IPNC Web网页之流程分析
    TI IPNC Web网页之GoDB开发环境
    安装ubuntu时将boot目录单独挂载的意义
    ubuntu添加自定义vga输出分辨率
    GCC编译默认的头文件搜索路径
    设置搜狗输入法在任何时候按左右两侧的shift激活
  • 原文地址:https://www.cnblogs.com/tianzhiyuan/p/12533470.html
Copyright © 2011-2022 走看看