- //package org.java.scb;
- import java.util.*;
- public class Login2 {
- public static void main(String[] args){
- String[] db ={"scb","小明","小花","奥巴马","小沈阳","金胖子","Josh","习总","刘德华","&_&"};
- String recordname;
- String recordpassword;
- Scanner name =new Scanner(System.in);
- Scanner password =new Scanner(System.in);
- Scanner judge =new Scanner(System.in);
- System.out.println("******************欢迎您注册JAVA会员******************\n");
- System.out.println("请输入您的昵称:");
- String str =name.next();
- for(int i=0;i<db.length;i++)
- if(str.equals(db[i])){
- System.out.println("该昵称已被注册,亲~换一个试试吧^_^");
- return;}
- System.out.println("请输入您的密码(注意:密码取空格无效!):");
- String pw =password.next();
- System.out.println("确认注册请按“1”,放弃注册请按“0”!");
- int jud =judge.nextInt();
- if(jud==1){
- recordname=str;
- recordpassword=pw;
- System.out.println("恭喜您! "+str+" 注册成功!现在就开启你的JAVA学习之旅吧!");
- System.out.println("现在请重新登录您的注册账号,这样您就可以享受更多的服务了。\n\n用户名:");
- String str1 =name.next();
- System.out.println("\n登录密码:");
- String pw1 =password.next();
- if(str1.equals(recordname) && pw1.equals(recordpassword))
- System.out.println("\n登录成功,欢迎回来! "+str1);
- else
- System.out.println("用户名或密码错误!请重新输入!");
- }
- else
- System.out.println("注册失败!请重新注册!");
- }
- }
复制代码 |
|