(1) package shiwushangjilianxi; import java.util.Scanner; public class shiwushangji_2 { String[] word=new String[2]; String shen; String ji; String zhu; public boolean show(){ boolean con = false; String word[]=zhu.split("-"); if(shen.length()>=16&&(shen.length()<=18)){ con=true; }else{ System.out.println("身份证必须是16位或18位!"); con = false; } if(ji.length()==11){ con=true; }else{ System.out.println("手机必须是11位!"); con = false; } if(word[0].length()==4 && (word[1].length()==7)){ con=true; }else{ System.out.println("座机号码区号必须为4位,电话号码必须为7位!"); con = false; } if ((shen.length() >= 16&&shen.length()<=18 ) && ji.length()==11 && word[0].length()==4 && ( word[1].length()==7)){ System.out.println("注册成功!"); con=true; }else{ con = false; } return con; } public static void main(String[] args) { shiwushangji_2 a = new shiwushangji_2(); Scanner input = new Scanner(System.in); boolean flag=false; System.out.println("***欢迎进入注册系统***"); System.out.println(""); do{ System.out.println("请输入身份证号:"); a. shen = input.next(); System.out.println("请输入手机号:"); a. ji = input.next(); System.out.println("请输入座机号:"); a. zhu = input.next(); boolean show = a.show(); if(show==true){ flag=true; } }while (flag==false); } }
时间: 2024-11-01 03:25:40