zoukankan      html  css  js  c++  java
  • Java经典习题26

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

    import java.util.*;

    public class Class26 {

    public static void main(String[] args) {
    System.out.println("输入第一个字母:");
    Scanner sc1 = new Scanner(System.in);
    String s1 = sc1.nextLine();
    char ch1 = s1.charAt(0);
    if(ch1 < 'A' || ch1 > 'Z' || ch1 < 'a' || ch1 > 'z'){
    //System.out.println("输入有误!");
    }
    switch(ch1){
    case 'M':
    System.out.println("星期一");
    break;
    case 'm':
    System.out.println("星期一");
    break;
    case 'W':
    System.out.println("星期三");
    break;
    case 'w':
    System.out.println("星期三");
    break;
    case 'F':
    System.out.println("星期五");
    break;
    case 'f':
    System.out.println("星期五");
    break;
    case 'T':
    System.out.println("请输入第二个字母:");
    Scanner sc2 = new Scanner(System.in);
    String s2 = sc2.nextLine();
    char ch2 = s2.charAt(0);
    if(ch2 < 'A' || ch2 > 'Z' || ch2 < 'a' || ch2 > 'z'){
    //System.out.println("输入有误!");
    }else if(ch2 == 'U'){
    System.out.println("星期二");
    }else if(ch2 == 'H'){
    System.out.println("星期四");
    }else{
    System.out.println("输入有误!");
    }
    break;
    case 't':
    System.out.println("请输入第二个字母:");
    Scanner sc3 = new Scanner(System.in);
    String s3 = sc3.nextLine();
    char ch3 = s3.charAt(0);
    if(ch3 < 'A' || ch3 > 'Z' || ch3 < 'a' || ch3 > 'z'){
    //System.out.println("输入有误!");
    }else if(ch3 == 'u'){
    System.out.println("星期二");
    }else if(ch3 == 'h'){
    System.out.println("星期四");
    }else{
    System.out.println("输入有误!");
    }
    break;
    case 'S':
    System.out.println("请输入第二个字母:");
    Scanner sc4 = new Scanner(System.in);
    String s4 = sc4.nextLine();
    char ch4 = s4.charAt(0);
    if(ch4 < 'A' || ch4 > 'Z' || ch4 < 'a' || ch4 > 'z'){
    //System.out.println("输入有误!");
    }else if(ch4 == 'A'){
    System.out.println("星期六");
    }else if(ch4 == 'U'){
    System.out.println("星期日");
    }else{
    System.out.println("输入有误!");
    }
    break;
    case 's':
    System.out.println("请输入第二个字母:");
    Scanner sc5 = new Scanner(System.in);
    String s5 = sc5.nextLine();
    char ch5 = s5.charAt(0);
    if(ch5 < 'A' || ch5 > 'Z' || ch5 < 'a' || ch5 > 'z'){
    //System.out.println("输入有误!");
    }else if(ch5 == 'u'){
    System.out.println("星期六");
    }else if(ch5 == 'h'){
    System.out.println("星期日");
    }else{
    System.out.println("输入有误!");
    }
    break;
    default:
    System.out.println("输入有误!");

    }

    }

    }

  • 相关阅读:
    Atitit 图像金字塔原理与概率 attilax的理解总结qb23
    Atiti  attilax主要成果与解决方案与案例rsm版 v4
    Atitit 常用比较复杂的图像滤镜 attilax大总结
    Atitit. Api 设计 原则 ---归一化
    Atitit 面向对象弊端与问题 坏处 缺点
    Atitit  记录方法调用参数上下文arguments
    Atitit 作用域的理解attilax总结
    Atitit usrQBM1603短信验证码规范
    atitit 短信验证码的源码实现  .docx
    Atitit 图片 验证码生成attilax总结
  • 原文地址:https://www.cnblogs.com/zhuozige/p/12358695.html
Copyright © 2011-2022 走看看