Answer to Question #258392 in Java | JSP | JSF for enitaf

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


1
Expert's answer
2021-10-29T00:53:50-0400


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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS