zoukankan      html  css  js  c++  java
  • 例题

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

    package a;
    import java.util.*;
    public class ScannerTest {
    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;
    }
    }

    对10个数进行排序。

  • 相关阅读:
    使用Python读取照片的GPS信息
    jquery animate自定义动画
    javascript 跨域名 精简
    c++ 多态
    sougou php mysql 调用
    smarty 快速入门
    html 表单模板
    stl helloworld 链表 快速入门
    解析C函数式宏
    宏常用例子
  • 原文地址:https://www.cnblogs.com/mjhjl/p/13584138.html
Copyright © 2011-2022 走看看