public static void main(String[] args) {
//1.告诉了已知的用户名和密码
String name = "zhangan";
String password = "12345";
Scanner sc = new Scanner(System.in);
//2.实现模拟用户登录
for (int i = 0; i < 3; i++) {
System.out.println("请输入用户名");
String str = sc.next();
System.out.println("请输入密码");
String str1 = sc.next();
if (name.equals(str) && password.equals(str1)) {
System.out.println("登录成功");
break;
}
if (i == 2) {
System.out.println("用户被锁定,请找客服解决" + "\n" + "电话为234-56890");
} else {
System.out.println("登录失败,请重新登录,剩余的机会为" + (2 - i) + "次!");
}
}
}