package com.heima;
import java.util.Scanner;
public class test_online {
public static void main(String[] args) {
for(int x=1;x<=3;x++){
Scanner sc =new Scanner(System.in );
System.out.println("请输入登陆账号:");
String account = sc.nextLine();
System.out.println("请输入密码:");
String password = sc.nextLine(); //nextLine是输入字符的,nextxxx 后面加什么可以输入什么样的类型.
if ("admin".equals(account )&&"admin".equals(password )){
System.out.println("欢迎回来!");
} else if (x<=2){
System.out.println("输入密码有误,请重新输入,还有"+(3-x)+"次机会");
}else {
System.out.println("输入密码或用户名有误,已锁卡!");
}
}
}
}
|
|