Java code to verify QQ No.

Qq number verification:
1. The requirement must be 5-15 digits
2.0 not begin

Analysis:
A: a keyboard input qq number
B: write a checksum function implemented
C: calling a function, the output.

Code implementation:
public class RegexDemo {
public static void main (String [] args) {
Scanner sc = new new Scanner (System.in);
System.out.println ( "Please enter your qq number");
String = qq sc. nextLine ();
System.out.println ( "checkQQ:" + checkQQ (QQ));
}

static Boolean checkQQ public (String QQ) {
Boolean = In Flag to true;

// check the length of the
IF (qq.length ()> =. 5 && qq.length () <= 15) {
// 0 can not begin
if (qq!. startsWith ( "0")) { // startsWith (string str) is the same as the beginning of a string parameter to check whether the parameters you want to check // and startsWith (Sring str, int Index) is from the character you want to compare the original string specified index parameter and comparing the start
// number must be
char [] = CHS qq.toCharArray ();
for (int X = 0; X <chs.length; X ++) {
char CH = CHS [X] ;
IF {(by Character.isDigit (CH)!)
In Flag to false =;
BREAK;
}
}

} the else {
In Flag = to false;
}
} the else {
In Flag = to false;
}
return In Flag;
}
}

Guess you like

Origin www.cnblogs.com/lszbk/p/12318615.html