java输入数字结果对应星期几用if else语句

如题所述

    public static void main(String args[]) {
     Scanner input=new Scanner(System.in);
     System.out.print("input a number: ");
     int weekday=input.nextInt();
     if ( weekday==1 )
     System.out.println("Monday");
     else if (weekday==2)
     System.out.println("Tuesday");
     else
     System.out.println("Other day");//其它的几天,你仿照着写一下吧
    }

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-03-25
做作业。。。