package com.heima.test;
import java.util.Scanner;
public class Test1 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i=0;i<3;i++){
System.out.println("请输入用户名");
String userName = sc.nextLine();
System.out.println("请输入密码");
String passWord = sc.nextLine();
if("admin".equals(userName)&&"admin".equals(passWord)){
System.out.println("欢迎"+userName+"登录");
break;
}else{if(i==2){6
System.out.println("您的次数已用完");
}else{
System.out.println("输入错误,还有"+(2-i)+"次机会");
}
}
}
}
} |
|