String username ="Dmy;
String password ="123456";
Scanner scanner = new Scanner(System.in);
int count =0;
while(count<3){
System.out.println("请输入用户名");
String name = scanner.nextLine();
System.out.println("请输入密码");
String word = scanner.nextLine();
if(username.equals(name)&&password.equals(word)){
System.out.println("登录成功");
break;
}else {
System.out.println("登录失败");
if(2-count!=0){
System.out.println("您的登录次数还剩下"+(2-count)+"次");
}else{
System.out.println("您今日的登录次数已经用完,请明日再试");
}
count++;
}
}
总结: 努力学习,天天向上!!!
{:8_472:}{:8_472:}{:8_502:} |
|