Question #258392

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".


Expert's answer



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();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS