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

  • 相关阅读:
    VS2008中 没有QT的代码智能提示
    QT的一个奇怪问题,设置了Qt::Tool后,点击弹出对话框的确定取消按钮,程序直接退出。
    QT线程初次使用。遇到的问题。
    QMenu,QT的菜单添加
    VS2008 不能创建C++的项目,解决方法
    VS2008工具,两种加入库的方法。 设置程序运行时目录
    得到弹出菜单QMenu的高度
    QT 修改QTableWidget表头
    QT两个字符串转化函数,避免文字乱码。
    改变QlistWidget的行高
  • 原文地址:https://www.cnblogs.com/kongtingting/p/7825104.html
Copyright © 2011-2022 走看看