Java判断星座的小玩意儿

入门Java做点小玩意儿来培养兴趣,emmm……(超简单的)^_^
—————————————————————————— 
@Test
public void testConstellation(){
Scanner sc=new Scanner(System.in);
//提示按照样例输入
System.out.println("请输入您的生日。eg:1-23");
//输入生日
String birthday=sc.next();
//用.切割,把月和日拿出来
int month=Integer.parseInt(birthday.split("-")[0]);
int day=Integer.parseInt(birthday.split("-")[1]);
switch (month) {
//判断是几月
case 1:
//判断是当前月的哪一段时间;然后就可以得到星座了;下面代码都一样的
if(day>0&&day<20){
System.out.println("魔蝎座哦");
}else if(day<32) System.out.println("水瓶座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 2:
if(day>0&&day<19){
System.out.println("水瓶座哦");
}else if(day<29) System.out.println("双鱼座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 3:
if(day>0&&day<21){
System.out.println("双鱼座哦");
}else if(day<32) System.out.println("白羊座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 4:
if(day>0&&day<20){
System.out.println("白羊座哦");
}else if(day<31) System.out.println("金牛座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 5:
if(day>0&&day<21){
System.out.println("金牛座哦");
}else if(day<32) System.out.println("双子座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 6:
if(day>0&&day<22){
System.out.println("双子座哦");
}else if(day<31) System.out.println("巨蟹座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 7:
if(day>0&&day<23){
System.out.println("巨蟹座哦");
}else if(day<32) System.out.println("狮子座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 8:
if(day>0&&day<23){
System.out.println("狮子座哦");
}else if(day<32) System.out.println("处女座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 9:
if(day>0&&day<23){
System.out.println("处女座哦");
}else if(day<31) System.out.println("天平座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 10:
if(day>0&&day<24){
System.out.println("天平座哦");
}else if(day<32) System.out.println("天蝎座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 11:
if(day>0&&day<23){
System.out.println("天蝎座哦");
}else if(day<31) System.out.println("射手座哦");
else System.out.println("这个月有几天都不知道吗");
break;
case 12:
if(day>0&&day<22){
System.out.println("射手座哦");
}else if(day<32) System.out.println("魔蝎座哦");
else System.out.println("这个月有几天都不知道吗");
break;
default:
System.out.println("木有这个月吧");
break;
}
}
—————————————————————————— 
第一次写这个,还希望能喜欢,

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值