public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = 5;
while(num > 0) {
System.out.println("欢迎登陆系统");
System.out.println("请输入用户名:");
String name = sc.nextLine();
System.out.println("请输入密码:");
String passWord = sc.nextLine();
if ("admin".equals(name) && "admin".equals(passWord) ) {
System.out.println("登陆成功请答题");
break;
}else{
System.out.println("姓名或密码错误,还有" + (--num) + "次机会");
}
}
} |
|