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

    package 第四次作业;
    public class X{
        public static void main(String[] args){
            //第六题判断语句
            int weekDay=3;//判断星期
            if(weekDay==1){
                System.out.println("今天是星期一");
            }
            else if(weekDay==2){
                System.out.println("今天是星期二");
            }
            else if(weekDay==3){
                System.out.println("今天是星期三");
            }
            else if(weekDay==4){
                System.out.println("今天是星期四");
            }
            else if(weekDay==5){
                System.out.println("今天是星期五");
            }
            else if(weekDay==6){
                System.out.println("今天是星期六");
            }
            else if(weekDay==7){
                System.out.println("今天是星期日");
            }
            else{
                System.out.println("没有这一天");
            }
            int month=8;//判断季节
            if(month==3||month==4||month==5){
                System.out.println("现在是春天");
            }
            else if(month==6||month==7||month==8){
                System.out.println("现在是夏天");
            }
            else if(month==9||month==10||month==11){
                System.out.println("现在是秋天");
            }
            else if(month==12||month==1||month==2){
                System.out.println("现在是冬天");
            }
            else{
                System.out.println("没有这个季节");
            }
            //第七题使用分支语句
            int c=84,h=3;
                char option='+';
                   switch (option)
                {
                case '+':
                        System.out.println("c+h="+(c+h));
                        break;
                case '-':
                        System.out.println("c-h="+(c-h));
                        break;
                case '*':
                        System.out.println("c*h="+(c*h));
                        break;
                case '/':
                        System.out.println("c/h="+(c/h));
                        break;
                case '%':
                        System.out.println("c%h="+(c%h));
                        break;
                default:
                        System.out.println("c%h="+(c%h));
                        break;
                }
            //使用switch判断季节
            int mon=8;
            switch(mon)
            {
            case 3:
            case 4:
            case 5:
                System.out.println("现在是春天");
                break;
            case 6:
            case 7:
            case 8:
                System.out.println("现在是夏天");
                break;
            case 9:
            case 10:
            case 11:
                System.out.println("现在是秋天");
                break;
            case 12:
            case 1:
            case 2:
                System.out.println("现在是冬天");
                break;
            default:
                System.out.println("没有这个季节");
                break;
            }
            //第八题do while和while的区别
            int d=1;
            do{
                System.out.println("d="+d);
                d++;
            }while(d<1);//不管while里面的条件是否成立,do里面的都要运行
            int f=1;
            while(f<1){
                System.out.println("f="+f);
                f++;
            }
            //第九题使用for语句写一个简单的循环语句
            for(int g=1;g<5;g++)
            {
                System.out.println("g="+g);
            }
        }
    }

  • 相关阅读:
    C# 斐波拉契数列
    Visual Studio [即时窗口] & [命令窗口] (Immediate Window & Command Window) 转
    在.NET平台下 有哪些数据持久层框架 (转)
    WebPart 控件之间通讯 笔记
    WebPart的数据库连接问题 转
    C 语言函数要先声明后定义
    C#单例模式的三种写法(转)
    WCF 绑定wshttpbinding
    关于C#中派生类调用基类构造函数的理解 base使用
    ThinkPHP3.* 模型操作相关函数
  • 原文地址:https://www.cnblogs.com/kongtingting/p/7825104.html
Copyright © 2011-2022 走看看