登录用户名密码是否合法

package com.sunhang.denglu;

import java.util.Scanner;

public class Denglu {
private static String name;
private static Scanner s;
private static boolean boo;
private static boolean bool;
private static String password;
public static void main(String[] args) {

s = new Scanner(System.in);
System.out.println("请输入您的账号:");
name = s.nextLine();
String[] shuzi = {"1","2","3","4","5","6","7","8","9","0"};
String[] zimu = {"a","b","c","d","e","f","g",
"h","i","j","k","l","m","n",
"o","p","q","r","s","t","u",
"v","w","x","y","z"};
if (name.length() >= 6) {
for (int i = 0; i < shuzi.length; i++) {
for (int j = 0; j < zimu.length; j++) {
if (name.indexOf(shuzi[i])>=0 && name.indexOf(zimu[j])>=0) {
//System.out.println("用户名合法,用户名为:" + name);
boo = true;
break;
}
}
}
}
if (boo == true) {
System.out.println("用户名合法,输入的用户名是:" + name);
s = new Scanner(System.in);
System.out.println("请输入您的密码");
password = s.nextLine();
if (password.length() >= 8) {
for (int i = 0; i < shuzi.length; i++) {
for (int j = 0; j < zimu.length; j++) {
if (password.indexOf(shuzi[i])>=0 && name.indexOf(zimu[j])>=0) {
//System.out.println("用户名合法,用户名为:" + name);
bool = true;
break;
}
}
}
}
if (bool == true) {
System.out.println("恭喜,注册成功!" + "\n"+ "账号为:" + name +
"\n" + "密码为:" + password );
}else {
System.out.println("输入的密码不够安全,请重新输入");
}


}else {
System.out.println("输入的用户名非法,请重新输入");
}



}


}

 

posted @ 2016-04-06 09:12  爪哇见习  阅读(256)  评论(0编辑  收藏  举报