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

    1.输入一个年份,判断是不是闰年(能被4整除但不能被100整除,或者能被400整除)
    package wjb;
    import java.util.Scanner;
    public class wjbc {
    
        public static void main(String[] args) {
            System.out.println("请输入年份");
            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.输入一个4位会员卡号,如果百位数字是3的倍数,就输出是幸运会员,否则就输出不是.
    package wjb;
    import java.util.Scanner;
    public class wjbc {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println("请输入四位会员卡号");
            Scanner input=new Scanner(System.in);
            int a=input.nextInt();
            int b;
            b=a/100%10;
            if(b%3==0){
                System.out.println("是幸运会员");
            }else{
                System.out.println("不是幸运会员");
            }
        }
    }


    3.已知函数,输入x的值,输出对应的y的值.
                          x + 3   ( x > 0 )
                   y =      0     ( x = 0 )
                          x2 –1  ( x < 0 )
    package wjb;
    import java.util.Scanner;
    public class wjbc {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println("请输入x");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            int y;
            if(x>0){
                y=x+3;
                System.out.println(y);
            }else if(x==0){
                y=0;
                System.out.println(y);
            }else if(x<0){
                y=x*2-1;
                System.out.println(y);
            }
        }
    }

    4.输入三个数,判断能否构成三角形(任意两边之和大于第三边)
    package wjb;
    import java.util.Scanner;
    public class wjbc {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println("请输入三个数");
            Scanner input=new Scanner(System.in);
            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("不能构成三角形");
            }
        }
    }

  • 相关阅读:
    Silverlight MMORPG WebGame游戏设计(三)Server和Client的暗号
    Silverlight MMORPG WebGame游戏设计(七)IsolatedStorage,想说爱你不容易
    如何在WP7上用XNA写2D游戏(四)
    Silverlight MMORPG WebGame游戏设计(六)Server和Client的婚后协议[附上完整15M游戏DEMO]
    我的2010年
    如何在WP7上用XNA写2D游戏(一)
    笑话一片
    设计模式简单概括总结2
    设计模式简单概括总结
    ExtJs 4 动态加载grid
  • 原文地址:https://www.cnblogs.com/w200100/p/12561565.html
Copyright © 2011-2022 走看看