java输入一个年份,利用Java实现从键盘输入一个年份,程序输出改年出生的人的生肖...
從鍵盤(pán)輸入一個(gè)年份,程序輸出改年出生的人的生肖。
import java.util.Scanner;
public class Sesx {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(“請(qǐng)輸入你的出生年份”);
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
如您對(duì)本文有疑問(wèn)或者有任何想說(shuō)的,請(qǐng)點(diǎn)擊進(jìn)行留言回復(fù),萬(wàn)千網(wǎng)友為您解惑!
總結(jié)
以上是生活随笔為你收集整理的java输入一个年份,利用Java实现从键盘输入一个年份,程序输出改年出生的人的生肖...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: red hat linux 9.0下载地
- 下一篇: Java入门数据类型转换(羊驼)