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.");
}
}
}
}
|
|