利用Java实现从键盘输入一个年份,程序输出改年出生的人的生肖
从键盘输入一个年份,程序输出改年出生的人的生肖。
import java.util.Scanner;
public class Sesx {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(“请输入你的出生年份”);
int year = sc.nextInt();
if (year%12 == 4) {
System.out.println(year+“年属鼠”);
}if (year%12 == 5) {
System.out.println(year+“年属牛”);
}if (year%12 == 6) {
System.out.println(year+“年属虎”);
}if (year%12 == 7) {
System.out.println(year+“年属兔”);
}if (year%12 == 8) {
System.out.println(year+“年属龙”);
}if (year%12 == 9) {
System.out.println(year+“年属蛇”);
}if (year%12 == 10) {
System.out.println(year+“年属马”);
}if (year%12 == 11) {
System.out.println(year+“年属羊”);
}if (year%12 == 0) {
System.out.println(year+“年属猴”);
}if (year%12 == 1) {
System.out.println(year+“年属鸡”);
}if (year%12 == 2) {
System.out.println(year+“年属狗”);
}if (year%12 == 3) {
System.out.println(year+“年属猪”);
}
}
}
本文地址:https://blog.csdn.net/weixin_52184815/article/details/109562159