import java.util.Scanner; public class nn{ public static void main(String[] args) { char i, j; System.out.println("please enter the first letter:"); Scanner input = new Scanner(System.in); String str = ""; str = input.next().toLowerCase(); // 转换成字符串 i = str.charAt(0); switch (i) { case 'm': System.out.println("Monday\n"); break; case 'w': System.out.println("Wednesday\n");break; case 'f': System.out.println("Friday\n"); break; case 't': System.out.println("please enter the next letter:"); str = input.next().toLowerCase(); j = str.charAt(0); if (j == 'u') System.out.println("Tuesday\n"); else if (j == 'h') System.out.println("Thursday\n"); else System.out.println("error\n"); break; case 's': System.out.println("please enter the next letter:"); // 转换成字符串 str = input.next().toLowerCase(); j = str.charAt(0); if (j == 'a') System.out.println("Saturday\n"); else if (j == 'u') System.out.println("Sunday\n"); else System.out.println("error\n"); break; default: System.out.println("error\n"); break; } } }
根据英文单词的第一个字母判断星期几
最新推荐文章于 2022-11-24 20:43:25 发布