黑马程序员技术交流社区
标题:
基础登录密码判断
[打印本页]
作者:
果蝇
时间:
2015-9-5 23:07
标题:
基础登录密码判断
package HomeWorkDay12;
import java.util.Scanner;
public class JoinTest {
public static void main(String[] args) {
String username = "admin";
String password = "admin";
Scanner sc = new Scanner(System.in);
int limit = 3;
for (int count = 0; count < limit; count++) {
System.out.print("Plase input the username:");
String name = sc.nextLine();
System.out.print("Plase input the password:");
String key = sc.nextLine();
if (name.equals(username) && key.equals(password)) {
System.out.println("Welcome!");
break;
} else {
if (count == limit - 1) {
System.out.println("Error!Please wait 24h.");
break;
}
System.out.println("Eorro.You also can try it " + (limit - 1 -count) + " count times.");
}
}
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2