当前位置 : 主页 > 编程语言 > c++ >

3.Java基础练习--输入数字1-7,输出相应的星期数

来源:互联网 收集:自由互联 发布时间:2021-07-03
gistfile1.txt import java.util.Scanner;public class play{public static void main(String[] args) {Scanner s = new Scanner(System.in);System.out.println("please input:");switch (s.nextInt()) {case 1:System.out.println("Monday");break;case 2:S
gistfile1.txt
import java.util.Scanner;
public class play
{
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("please input:");
		switch (s.nextInt()) 
		{
			case 1:
				System.out.println("Monday");
				break;
			case 2:
				System.out.println("Tuesday");
				break;
			case 3:
				System.out.println("Wednesday");
				break;
			case 4:
				System.out.println("Thursday");
				break;
			case 5:
				System.out.println("Friday");
				break;
			case 6:
				System.out.println("Saturday");
				break;
			case 7:
				System.out.println("Sunday");
				break;
			
			default:
				break;
		}
	}
}
网友评论