@ Value indicates the ID card number entered by the user.
I only know that when the number at the end of the ID card number is an odd number, the gender is male; when the number is an even number, the gender is female.
However, in some special cases, for example, if the last digit is a letter,
One is X and the other is E, both are male, so I am trying to judge it as a special case, ladies and gentlemen, you
Do you usually encounter similar situations? Do you use the ID card number for additional features? Help me, because I don't
You know the gender of the user whose last ID card number is another letter.
Thank you!
Public String execute (String value)
{
Value = value. trim ();
If (value = null | (value. length ()! = 15 & value. length ()! = 18 ))
{
Return "";
}
If (value. length () = 15 | value. length () = 18)
{
String lastValue = value. substring (value. length ()-1, value. length ());
Int sex;
If (lastValue. trim (). toLowerCase (). equals ("x") | lastValue. trim (). toLowerCase (). equals ("e "))
{
Return "Mr ";
}
Else
{
Sex = Integer. parseInt (lastValue) % 2;
Return sex = 0? "Lady": "Mr ";
}
}
Else
{
Return "";
}
}
Finished!