标签:
import java.util.*;
public class Card { public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("请输入身份证号码:");
String numberCard = input.next();
char c[] =numberCard.toCharArray();
if(c.length==18){
String s1 =numberCard.substring(0,2);
int s=Integer.parseInt(s1);
String year = numberCard.substring(6,10);
String month = numberCard.substring(10,12);
String day = numberCard.substring(12,14);
String gender = numberCard.substring(16,17);
int y=Integer.parseInt(year);
int m =Integer.parseInt(month);
int d =Integer.parseInt(day);
int g = Integer.parseInt(gender);
if(y<2016&&m<13&&d<32){
switch(s){
case 11:
System.out.println("省份:北京");
break;
case 12:
System.out.println("省份:天津");
break;
case 13:
System.out.println("省份:河北");
break;
case 14:
System.out.println("省份:山西");
break;
case 15:
System.out.println("省份:内蒙古");
break;
case 21:
System.out.println("省份:辽宁");
break;
case 22:
System.out.println("省份:吉林");
break; case 23:
System.out.println("省份:黑龙江");
break;
case 31:
System.out.println("省份:上海");
break; case 32:
System.out.println("省份:江苏");
break;
case 33:
System.out.println("省份:浙江");
break;
case 35:
System.out.println("省份:福建");
break;
case 36:
System.out.println("省份:江西");
break;
case 37:
System.out.println("省份:山东");
break;
case 41:
System.out.println("省份:河南");
break;
case 42:
System.out.println("省份:湖北");
break;
case 43:
System.out.println("省份:湖南");
break;
case 44:
System.out.println("省份:广东");
break;
case 45:
System.out.println("省份:广西");
break;
case 46:
System.out.println("省份:海南");
break;
case 50:
System.out.println("省份:重庆");
break;
case 51:
System.out.println("省份:四川");
break;
case 52:
System.out.println("省份:贵州");
break;
case 53:
System.out.println("省份:云南");
break;
case 54:
System.out.println("省份:西藏");
break;
case 61:
System.out.println("省份:陕西");
break;
case 62:
System.out.println("省份:甘肃");
break;
case 63:
System.out.println("省份:青海");
break;
case 64:
System.out.println("省份:宁夏");
break;
case 65:
System.out.println("省份:新疆");
break;
case 71:
System.out.println("省份:台湾");
break;
case 81:
System.out.println("省份:香港");
break;
case 82:
System.out.println("省份:澳门");
break;
default:
System.out.println("输入的身份证号码不是中国的!");
}
System.out.println("出生日期:"+year+"-"+month+"-"+day);
System.out.println("年龄:"+(2015-y));
if(g%2==1){
System.out.println("性别:男");
}
else{
System.out.println("性别:女"); }
if(m==1&&d>=21||m==2&&m<=19){
System.out.println("星座:水瓶座");
}
else if(m==2&&d>=20||m==3&&d<=20) {
System.out.println("星座:双鱼座");
}
else if(m==3&&d>=21||m==4&&d<=20) {
System.out.println("星座:白羊座");
}
else if(m==4&&d>=21||m==5&&d<=21) {
System.out.println("星座:金牛座");
}
else if(m==5&&d>=22||m==6&&d<=21) {
System.out.println("星座:双子座");
}
else if(m==6&&d>=22||m==7&&d<=22) {
System.out.println("星座:巨蟹座");
}
else if(m==7&&d>=23||m==8&&d<=23) {
System.out.println("星座:狮子座");
}
else if(m==8&&d>=24||m==9&&d<=23) {
System.out.println("星座:处女座");
}
else if(m==10&&d>=24||m==11&&d<=22) {
System.out.println("星座:天蝎座");
}
else if(m==11&&d>=23||m==12&&d<=21) {
System.out.println("星座:射手座");
}
else if(m==12&d>=22||m==1&&d<=20) {
System.out.println("星座:摩羯座");
}
}
else{
System.out.println("输入的身份证有误!");
}
}
else{
System.out.println("输入的身份证有误!");
}
}
/*private static int Integer(String str) {
// TODO 自动生成的方法存根 return 0; }*/
}
实现的结果:
标签:
原文地址:http://www.cnblogs.com/12-2/p/4822035.html