1_Java考试.zip
立即下载
资源介绍:
1_Java考试.zip
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dengluzhuce;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Dengluzhuce {
public static void main(String[] args) {
String[][] userData = new String[10][2];
while(true){
System.out.println("**欢迎使用注册系统**");
System.out.println("1.登录");
System.out.println("2.注册");
System.out.println("3.查看");
System.out.println("4.退出");
System.out.println("请选择功能序号:");
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
switch(a){
case 1:
System.out.println("请输入用户名:");
String name = sc.next();
System.out.println("请输入密码");
String password = sc.next();
for (int i = 0;i < userData.length; i++){
if (userData[i][0]!=null&&name.equals(userData[i][0])&&password.equals(userData[i][1])){
System.out.println("登录成功!");
break;
}
else{
System.out.println("账号或密码有误,请重试!");
break;
}
}
break;
case 2:
System.out.println("请输入用户名:");
String inputname = sc.next();
System.out.println("请输入密码");
String inputpassword = sc.next();
for (int i = 0;i < userData.length; i++){
if (userData[i][0]==null){
userData[i][0]=inputname;
userData[i][1]=inputpassword;
break;
}
}
break;
case 3:
System.out.println("用户名\t"+"密码");
for (int i = 0;i < userData.length; i++){
System.out.println(userData[i][0]+"\t"+userData[i][1]);
System.out.println();
}
break;
case 4:
System.out.println("再见!");
System.exit(0);
break;
default:
System.out.println("输入有误,请重新输入");
break;
}
}
}
}