JAVA.已知今天日期(周几),求输入的天数后是周几------JAVA入门基础教程

        static Scanner in = new Scanner(System.in);

        

        System.out.println("今天是周几?");

        int a = in.nextInt();
        int b = in.nextInt();
        while(b > 0)
        {
            a++;
            b--;
            if(a > 7)
            {
                a = 1;
            }
        }
        System.out.println("今天是周"+a);
        int week = 2;
        week += 10;
        week %= 7;
        System.out.println("今天是周"+((week == 0)?"日":week));

你可能感兴趣的:(JAVA随手写,eclipse,java,intellij-idea,数据结构,jar)