Exercise
Password
Objetive
Write a java program to prompt the user to enter their login and password (both must be integer numbers) and repeat the prompt as many times as necessary until the entered login is "12" and the password is "1234".
Example Code
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int user, pass;
do
{
System.out.print("Enter a user: ");
user = Integer.parseInt(new Scanner(System.in).nextLine());
System.out.print("Enter a password: ");
pass = Integer.parseInt(new Scanner(System.in).nextLine());
if ((user != 12) || (pass != 1234))
{
System.out.println("Login Error");
}
} while ((user != 12) || (pass != 1234));
System.out.println("Login successful");
}
}