java练习--实现会员注册升级

时间:2022-09-04 13:29:35
import java.util.Scanner;

public class Shenfen {
	public static void main(String[] args) {
		Shenfen s = new Shenfen();
		Scanner input = new Scanner(System.in);
		boolean a = false;
		boolean b = false;
		boolean c = false;
		do {
			System.out.println("请输入身份证号:");
			String n = input.next();
			System.out.println("请输入手机号:");
			String q = input.next();
			System.out.println("请输入座机号:");
			String z = input.next();
			String zj[] = new String[30];
			zj = z.split("-");
			for (int i = 0; i < zj.length; i++) {
				
			}
			String x = z.substring(0, 4);
			String xz = z.substring(4, 10);
			if (x.length() != 4 || xz.length() != 7) {
				System.out.println("座机号码区号必须为4位,电话号码必须是7位");
			} else {
				c = true;
			}
			if (n.length() != 16) {
				System.out.println("身份证号必须是16或18位");
			} else if (n.length() != 18) {
				System.out.println("身份证号必须是16或18位");
			} else {
				a = true;
			}
			if (q.length() != 11) {
				System.out.println("手机号必须是11位");
			} else {
				b = true;
			}
			if (a & b & c) {
				System.out.println("注册成功");
			}
		} while (!c);
	}
}