Java:输入星期几的数字,输出该数字中文版和英文版

import java.util.Scanner;

public class haohao {
    public static void main(String[] args) {
        System.out.print("今天星期几?");
        System.out.println("(请输入1-7的数字)");
        int dayofweek = new Scanner(System.in).nextInt();
        showweekchinese(dayofweek-1);
        showweekenglish(dayofweek-1);
    }
    public static void showweekchinese(int dayofweek){
        String[]weekdays ={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
        System.out.println(weekdays[dayofweek]);
    }
    public static void showweekenglish(int dayofweek){
        String[]weekdays ={"monday","tueday","wedday","thuday","friday","satday","sunday"};
        System.out.println(weekdays[dayofweek]);
    }
}

运行结果:

今天星期几?(请输入1-7的数字)
3
星期三
wedday
 

猜你喜欢

转载自blog.csdn.net/weixin_44015669/article/details/89499483