Skip to content

Instantly share code, notes, and snippets.

@KingSirLee
Last active December 15, 2015 17:39
Show Gist options
  • Save KingSirLee/5297897 to your computer and use it in GitHub Desktop.
Save KingSirLee/5297897 to your computer and use it in GitHub Desktop.
账户密码连续输入三次,提示该账户被冻结。。
public class Login{
public static void main(String[]args){
java.util.Scanner input=new java.util.Scanner(System.in);
int errorNum=0;
String Lastname="";
while(true){
System.out.println("请输入账户:");
String name=input.next();
System.out.println("请输入密码:");
String password=input.next();
if(name.equals("Tom")&&password.equals("123")){
System.out.println("登陆成功! 欢迎Tom的到来!");
break;
}else{
if(!name.equals(Lastname)){
Lastname=name;
errorNum=0;
}
errorNum++;
if(errorNum==3){
System.out.println("密码连续输错3次,该账户也被冻结!");
break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment