zoukankan      html  css  js  c++  java
  • 【程序26】

    题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。

    
    import java.util.*;
    
    public class lianxi26 {
    
        public static void main(String[] args) {
    
            getChar tw = new getChar();
    
            System.out.println("请输入星期的第一个大写字母:");
    
            char ch = tw.getChar();
    
            switch(ch) {
    
                case "M": 
    
                    System.out.println("Monday");
    
                    break;
    
                case "W": 
    
                    System.out.println("Wednesday");
    
                    break;
    
                case "F":
    
                    System.out.println("Friday");
    
                    break;
    
                case "T": {
    
                    System.out.println("请输入星期的第二个字母:");
    
                    char ch2 = tw.getChar();
    
                    if(ch2 == "U") {System.out.println("Tuesday"); }
    
                    else if(ch2 == "H") {System.out.println("Thursday"); }
    
                    else {System.out.println("无此写法!");}
    
                 }; 
    
                  break;
    
                case "S": {
    
                    System.out.println("请输入星期的第二个字母:");
    
                    char ch2 = tw.getChar();
    
                    if(ch2 == "U") {System.out.println("Sunday"); }
    
                    else if(ch2 == "A") {System.out.println("Saturday"); }
    
                    else {System.out.println("无此写法!");}
    
                 };
    
                  break;
    
                default:System.out.println("无此写法!");
    
            }
    
           }
    
    }
    
    
    
    class getChar{
    
    public char getChar() {
    
        Scanner s = new Scanner(System.in);
    
        String str = s.nextLine();
    
        char ch = str.charAt(0);
    
        if(ch<"A" || ch>"Z") {
    
         System.out.println("输入错误,请重新输入");
    
         ch=getChar();
    
        }
    
        return ch;
    
    }
    
    }
  • 相关阅读:
    洛谷P3157 [CQOI2011]动态逆序对
    CDQ分治
    快速数论变换(NTT)
    洛谷P3338 [ZJOI2014]力
    洛谷 P1919 A*B Problem升级版
    0-1分数规划
    洛谷P4593 [TJOI2018]教科书般的亵渎
    拉格朗日插值
    20180912-3 词频统计
    20190912-1 每周例行报告
  • 原文地址:https://www.cnblogs.com/yuyu666/p/9840173.html
Copyright © 2011-2022 走看看