package com.foreknow.test;
import java.util.Scanner;
public class LoopDemo2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String proceed = "Y";
boolean online = false;
String name = "";
String password = "";
int safeIn = 3;
while (proceed.equals("Y")) {
System.out.println("----------------------");
System.out.println("-------1.注册---------");
System.out.println("-------2.登录---------");
System.out.println("-------3.抽奖---------");
System.out.println("---------------------");
System.out.print("请选择菜单:");
int choice = input.nextInt();
if (choice == 1) {
if (online == false) {
System.out.println("注册");
System.out.println("请输入用户名:");
name = input.next();
System.out.println("请输入密码");
password = input.next();
System.out.println("注册成功,请记好您的个人信息");
System.out.println("用户名\t密码\t会员卡号");
System.out.println(name + "\t" + password + "\t" + (int) ((Math.random() * 9 + 1) * 1000));
online = true;
} else if (online == true) {
System.out.println("注册过,请登录");
}
} else if (choice == 2) {
if (online == true) {
System.out.println("登录");
String nameTest = "";
String passWordTest = "";
System.out.println("请输入用户名:");
nameTest = input.next();
System.out.println("请输入密码:");
passWordTest = input.next();
while (safeIn > 0) {
if (nameTest.equals(name) && passWordTest.equals(password)) {
System.out.println("欢迎!");
safeIn = 3;
break;
} else {
safeIn--;
System.out.println("您还有" + safeIn + "次机会");
break;
}
}
} else if (online == false) {
System.out.println("未注册,请先注册");
}
} else if (choice == 3) {
System.out.println("抽奖");
}
System.out.print("是否继续(Y/N):");
proceed = input.next();
}
System.out.println("系统退出");
}
}
Java没有数据库的简单注册登录
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 1、首先建立一个jsp文件,里面设置一个form,注意form通过action映射到服务器,(以下提及到的Logi...