package IDcard;
import java.util.Scanner;
import Pattern;
public class IDcard {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入身份证号");
String ();
String year=new String();
String month=new String();
String day=new String();
String code=new String();
// String code1=id.substring(0, 6);
if(id.length()==15){
year=id.substring(6, 8);
month=id.substring(8, 10);
day=id.substring(10, 12);
code=id.substring(12);
System.out.println(shunxu(code));
birthday(year,month,day);
if(birthday(year,month,day).length()!=0){
System.out.println(birthday(year,month,day));
System.out.println("该身份证是旧假的");
}
else{
System.out.println(shunxu(code));
System.out.println("该居民的生日为"+year+"年"+month+"月"+day+"日");
System.out.println("该身份证是旧的");
}
}
else if(id.length()==18){
year=id.substring(6, 10);
month=id.substring(10, 12);
day=id.substring(12, 14);
code=id.substring(14, 17);
char code2=id.charAt(17);
String code4 = String.valueOf(code2);
birthday(year,month,day);
if(birthday(year,month,day).length()!=0||jiaoyan(id,code4).length()==10){
System.out.println(birthday(year,month,day));
System.out.println(jiaoyan(id,code4));
System.out.println("该身份证是假的");
}
else{
System.out.println(shunxu(code));
System.out.println("该居民的生日:"+year+"年"+month+"月"+day+"日");
System.out.println(jiaoyan(id,code4));
System.out.println("该身份证是真的");
}
}
else{
System.out.println("该身份证是假的");
}
}
public static String address(String code1){
String s=new String();
String place("11", "北京").replace("12", "天津").replace("13", "河北").replace("14", "山西")
.replace("15", "内蒙古").replace("21", "辽宁").replace("22", "吉林").replace("23", "黑龙江")
.replace("31", "上海").replace("32", "江苏").replace("33", "浙江") .replace("34", "安徽")
.replace("35", "福建").replace("36", "江西").replace("37", "山东").replace("37", "山东")
.replace("42", "湖北").replace("43", "湖南").replace("44", "广东").replace("45", "广西")
.replace("46", "海南").replace("50", "重庆").replace("51", "四川").replace("52", "贵州")
.replace("53", "云南").replace("54", "西藏").replace("61", "陕西").replace("62", "甘肃")
.replace("63", "青海").replace("64", "宁夏").replace("65", "新疆").replace("71", "台湾")
.replace("82", "澳门").replace("91", "国外").replace("81", "香港");
if(code11.equals(code1)){
s="该身份证地址编码是错的";
}
else{
s="该身份证省份为:"+code11;
}
return s;
}
public static String birthday(String year,String month,String day){
int i=Integer.parseInt(year);
int j=Integer.parseInt(month);
int z=Integer.parseInt(day);
StringBuffer error1 =new StringBuffer();
String error=new String();
java replace方法 if (i > 2015 || i == 0) {
error= "该身份证年份是错的 ";
error1.append(error);
}
if ( j> 12 || j == 0) {
error= "该身份证月份是错的 ";
error1.append(error);
}
if (z > 31 || z == 0) {
error= "该身份证日期是错的 ";
error1.append(error);
}
String error2 =new String(error1);
return error2;
}
public static String shunxu(String code){
int i=Integer.parseInt(code);
String s=new String();
if(i%2==0){
s="性别:女 ";
}
else{
s="性别:男";
}
return s;
}
public static String jiaoyan(String id,String code4){
int s=0;
Integer[] w = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
String a=new String();
for(int i=0;i<17;i++){
int ai=Integer.parseInt(String.valueOf(id.charAt(i)) );
int wi=w[i];
s+=ai*wi;
};
int b=s%11;
String b1=String.valueOf(b);
String b0="目"+b1;
String place("目10", "2").replace("目0", "1").replace("目1", "0").replace("目2", "X").replace("目3", "9")
.replace("目4", "8").replace("目5", "7").replace("目6", "6").replace("目7", "5")
.replace("目8", "4").replace("目9", "3");
if(b2.equals(code4)){
a="该身份证验证码是正确的";
}
else{
a="该身份证验证码是错的";
}
return a;
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论