PackageCom.swift; Public classId_where_male_test { Public Static voidMain (string[] args) {/** People's Republic of China Citizen identity card number composition rule is the first 4 is representative of the provinces and regions (for example, 4201 for Wuhan, Hubei Province), * the 17th digit represents the gender (odd for men). Write a procedure that determines whether a person is a Wuhan person and its gender through the ID number. */String str= "420103199801010312"; if(str.substring (0, 4). Equals ("4201") {System.out.println ("This man is from Wuhan, Hubei province. "); }Else{System.out.println ("This man is not from Wuhan, Hubei. "); } intSex=17; if(Str.charat (sex-1)%2==1) {System.out.println ("This man is male. "); }Else{System.out.println ("This person is female. "); } }}
PackageCom.swift; Public classId_where_male_test { Public Static voidMain (string[] args) {/** People's Republic of China Citizen identity card number composition rule is the first 4 is representative of the provinces and regions (for example, 4201 for Wuhan, Hubei Province), * the 17th digit represents the gender (odd for men). Write a procedure that determines whether a person is a Wuhan person and its gender through the ID number. */String str= "420103199801010312"; if(str.substring (0, 4). Equals ("4201") {System.out.println ("This man is from Wuhan, Hubei province. "); }Else{System.out.println ("This man is not from Wuhan, Hubei. "); } intSex=17; if(Str.charat (sex-1)%2==1) {System.out.println ("This man is male. "); }Else{System.out.println ("This person is female. "); } }}
The Java Practice Certificate number composition rule is that the first 4 are to represent provinces and regions to prepare a procedure to determine whether a person is a Wuhan person and its gender through the ID number.