package String;
import java.util.Scanner;
public class S02 {
public static void main(String[] args) {
String mingcheng="潘坤";
String mima="既爱江山,又爱美人";
Scanner sc=new Scanner(System.in) ;
for (int i = 2; i >=0 ; i--) {
System.out.println("请输入用户名:");
String a=sc.nextLine();
System.out.println("请输入用户密码:");
String b =sc.nextLine();
if (a.equals(mingcheng)&&b.equals(mima)){
System.out.println("登陆成功!");
break;
}else if (i==0){
System.out.println("你的账户已经被锁定,请与管理员联系!");
}else{
System.out.println("登陆失败,您还剩"+i+"次机会");
}
}
}
} |
|