Write a Java program to ask the user for their login and their password (both must be integer numbers) and repeat it as many times as necessary, until the entered login is "10" and the password is "0123".
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
boolean isCorrect = false;
while (!isCorrect) {
System.out.print("Enter login: ");
int login = keyBoard.nextInt();
System.out.print("Enter password: ");
int password = keyBoard.nextInt();
if (login == 10 && password == 123) {
isCorrect = true;
} else {
System.out.println("\nWrong login or password. Try again.\n");
}
}
System.out.println("\nCorrect login and password.");
keyBoard.close();
}
}
Comments
Leave a comment