新旧身份证的转换

上传人:子 文档编号:41844604 上传时间:2018-05-31 格式:DOC 页数:8 大小:29KB
返回 下载 相关 举报
新旧身份证的转换_第1页
第1页 / 共8页
新旧身份证的转换_第2页
第2页 / 共8页
新旧身份证的转换_第3页
第3页 / 共8页
新旧身份证的转换_第4页
第4页 / 共8页
新旧身份证的转换_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《新旧身份证的转换》由会员分享,可在线阅读,更多相关《新旧身份证的转换(8页珍藏版)》请在金锄头文库上搜索。

1、新旧身份证的转换新旧身份证的转换回答人的补充 2009-10-29 19:03 /最后 3 位(18 位身份证最后4 位),是序号,表示办理身份证的第几名,/其中性别在最后一位表示(18 位身份证在倒数第二位),奇数是男性,偶数是女性. import java.util.*;public class IdentityNumber public static void main(String args) Scanner stdIn = new Scanner(System.in);String input = stdIn.nextLine();int length = input.length(

2、);for (int i = 0; i 9)| i = 17 i-)double wi = Math.pow(2,(i-1) %11;int ai = (int)temp3.charAt(i);index += ai*wi;index = index % 11;index = (int)this.ccindex;return index;public String makeit(String temp2)StringBuffer temp3 = new StringBuffer(temp2);temp3.insert(6,“19“);temp3.insert(17,LastNum(temp3.

3、toString();return temp3.toString();public static void main(String args)ID id = new ID();id.temp = id.getID();id.checkit();import java.io.*;public class IDprivate String temp ;private final char cc = 1,0,X,9,8,7,6,5,4,3,2;public String getID()trySystem.out.println(“Input ID,please input“);BufferedRea

4、der br = new BufferedReader(new InputStreamReader(System.in);temp = br.readLine();catch(IOException e)System.out.println(“ make sure of it:“+temp);return temp;public void checkit()String temp1 = temp;if(temp1.length() = 18)System.out.println(temp1.substring(6,10)+“year “+temp1.substring(10,12)+“mont

5、h “+temp1.substring(12,14)+“day “+“sex: “+checkSex(temp1.charAt(16) );else if(temp1.length() = 15)String id = makeit(temp1);System.out.println(id.substring(6,10)+“year “+id.substring(10,12)+“month “+id.subSequence(12,14)+“day “+“sex: “+ checkSex(id.charAt(16);elseSystem.out.println(“your input is Er

6、ror,please input again!“);public String checkSex(char c)if(c%2 = 0)return “girl“;elsereturn “boy“;public int LastNum(String temp3)int index = 0;for(int i = 16;i= 0;i-)double wi = Math.pow(2,(i-1) %11;int ai = (int)temp3.charAt(i);index += ai*wi;index = index % 11;index = (int)this.ccindex;return index;public String makeit(String temp2)StringBuffer temp3 = new StringBuffer(temp2);temp3.insert(6,“19“);temp3.insert(17,LastNum(temp3.toString();return temp3.toString();public static void main(String args)ID id = new ID();id.temp = id.getID();id.checkit();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号