1. 程式人生 > >第十五章

第十五章

ext return oid lean clas code inpu color div

(1package 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); } }

第十五章