import java.util.Scanner;
public class RegisterTest2 {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("***欢迎进入注册系统***");
boolean finall;
do{
Register2 zhuce=new Register2();
System.out.println("请输入身份证:");
String IDCard=input.next();
System.out.println("请输入手机号:");
String Tel=input.next();
System.out.println("请输入座机号:");
String phone=input.next();
String[] num=new String[2];
num=phone.split("-");
String ch="-";
int index=phone.indexOf(ch);
int index2=phone.lastIndexOf(ch);
finall=zhuce.indexOf(IDCard, Tel, index, index2);
}while(finall);
System.out.println("注册成功!");
}
}
public class Register2 {
public boolean indexOf(String IDCard,String Tel,int index,int index2){
boolean flag=true;
if(IDCard.length()!=18&&IDCard.length()!=16){
System.out.println("身份证号必须是16位或18位!");
}else if(Tel.length()!=11){
System.out.println("手机号必须是11位!");
}else if(index!=4||index2!=12){
System.out.println("座机号码区号必须为4位,电话号码必须是7位!");
}else{
flag=false;
}
return flag;
}
}
**********希望能帮到你!****************
温馨提示:答案为网友推荐,仅供参考