package com.kevin.test;
import java.util.Scanner;
public class Demo1_munidenglu {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 0;
while(++i<=3){
System.out.println("请输入用户名:");
String usrname = sc.nextLine();
System.out.println("请输入密码:");
String password = sc.nextLine();
if("admin".equals(password)&&"admin".equals(usrname)){
System.out.println("登录成功");
break;
}else{
if(3-i ==0){
System.out.println("输入三次错误,请明日再来");
}else{
System.out.println("你还有"+(3-i)+"次机会");
}
}
}
}
}
|
|