zoukankan      html  css  js  c++  java
  • JAVA 基础编程练习题26 【程序 26 求星期】

    26 【程序 26 求星期】

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

    程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或 if 语句判断第二个字母。

    package cskaoyan;
    
    public class cskaoyan26 {
    	@org.junit.Test
    	public void days() {
    		java.util.Scanner in = new java.util.Scanner(System.in);
    		System.out.print("please input:");
    		char ch = in.next().charAt(0);
    
    		if (ch == 'M' || ch == 'm') {
    			System.out.println("Monday");
    		} else if (ch == 'T' || ch == 't') {
    			System.out.print("please input second letter:");
    			ch = in.next().charAt(0);
    			if (ch == 'U' || ch == 'u') {
    				System.out.println("Tuesday");
    			} else if (ch == 'H' || ch == 'h') {
    				System.out.println("Thursday");
    			} else {
    				System.out.println("data error");
    			}
    		} else if (ch == 'W' || ch == 'w') {
    			System.out.println("Wednesday");
    		} else if (ch == 'F' || ch == 'f') {
    			System.out.println("Friday");
    		} else if (ch == 'S' || ch == 's') {
    			System.out.print("please input second letter:");
    			ch = in.next().charAt(0);
    			if (ch == 'A' || ch == 'a') {
    				System.out.println("Saturday");
    			} else if (ch == 'U' || ch == 'u') {
    				System.out.println("Sunday");
    			} else {
    				System.out.println("data error");
    			}
    		} else {
    			System.out.println("data error");
    		}
    
    		in.close();
    	}
    }
    
  • 相关阅读:
    border-radius
    border-style
    border-width
    border
    max-width
    min-width
    clip 语法
    left
    z-index
    position
  • 原文地址:https://www.cnblogs.com/denggelin/p/11397728.html
Copyright © 2011-2022 走看看