日期:2014-05-20 浏览次数:20874 次
import java.util.Scanner; public class ConstallationDemo { static void getConstallation(int month,int day) { if(day > 31 || day<1) System.out.println("日期输入错误"); else { switch(month) { case 1: if(day<22) System.out.println("星座是:摩羯座"); else System.out.println("星座是:水瓶座"); break; case 2: if(day<22) System.out.println("星座是:水瓶座"); else System.out.println("星座是:双鱼座"); break; case 3: if(day<22) System.out.println("星座是:双鱼座"); else System.out.println("星座是:白羊座"); break; case 4: if(day<22) System.out.println("星座是:白羊座"); else System.out.println("星座是:金牛座"); break; case 5: if(day<22) System.out.println("星座是:金牛座"); else System.out.println("星座是:双子座"); break; case 6: if(day<22) System.out.println("星座是:双子座"); else System.out.println("星座是:巨蟹座"); break; case 7: if(day<22) System.out.println("星座是:巨蟹座"); else System.out.println("星座是:狮子座"); break; case 8: if(day<22) System.out.println("星座是:狮子座"); else System.out.println("星座是:处女座"); break; case 9: if(day<22) System.out.println("星座是:处女座"); else System.out.println("星座是:天枰座"); break; case 10: if(day<22) System.out.println("星座是:天枰座"); else System.out.println("星座是:天蝎座"); break; case 11: if(day<22) System.out.println("星座是:天蝎座"); else System.out.println("星座是:射手座"); break; case 12: if(day<22) System.out.println("星座是:射手座"); else System.out.println("星座是:摩羯座"); break; default: System.out.println("日期输入错误"); } } } public static void main(String[] args){ Scanner scanner=new Scanner(System.in); System.out.print("请输入你的出生月份"); int month=scanner.nextInt(); System.out.print("请输入你的出生日期"); int day=scanner.nextInt(); getConstallation(month,day); } }