//导入Scanner包;
import java.util.Scanner;
class Demo8
{
public static void main(String[] args)
{
//创建一个对象;
Scanner as=new Scanner(System.in);
System.out.print("请输入一个数字:");
int num=as.nextInt();
//循环语句,判断星期几;
switch (num)
{
case 1:
System.out.println("今天:"+"星期一");
break;
case 2:
System.out.println("今天:"+"星期二");
break;
case 3:
System.out.println("今天:"+"星期三");
break;
case 4:
System.out.println("今天:"+"星期四");
break;
case 5:
System.out.println("今天:"+"星期五");
break;
case 6:
System.out.println("今天:"+"星期六");
break;
case 7:
System.out.println("今天:"+"星期日");
break;
default:
System.out.println("今天:"+"输错了");
}
}
}
|
|