public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
int count = 3;
while (count != 0) {
System.out.println("请输入你的密码:");
String password = sca.nextLine();
//if(password == "abcde") {
//if(password.equals("abcde")) {
if ("abcde".equals(password)) {
System.out.println("输入正确!");
break;
} else {
System.out.println("密码错误!");
count--;
}
}
}
java 编写代码模拟三次密码输入的场景。 最多能输入三次密码,密码正确,提示“登录成功”,密码错误, 可以重新输 入,最多输入三次。三次均错,则提示退出程序
最新推荐文章于 2023-12-08 06:25:24 发布