I have made this piece of code where the output should display a dialogue box asking for a password. Then if the user enters it correctly it displays "Valid" or else it displays "Not Valid". However its only dispalying the dialogue box to enter the password. It isn't displaying whether its valid or not. What have i made wrong? Thanks a lot.
PS: I'm still a beginner in java
This is the piece of code i have written:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
public class GeographyQuiz_Menu
{
public static void main(String[] args)
{
JFrame jFrame;
jFrame = new JFrame();
JOptionPane.showMessageDialog(jFrame, "This is a Geography Quiz");
JOptionPane.showMessageDialog(null, "Good Luck");
String yourChoice;
char choice;
int i, choice1;
int Password;
Scanner keyboard = new Scanner(System.in);
JOptionPane.showInputDialog(jFrame, "Enter the Password");
Password = keyboard.nextInt();
if (Password == 123)
{
JOptionPane.showMessageDialog(null, "Valid. You typed the right password. Now choose from the following menu");
}
else
{
JOptionPane.showMessageDialog(null, "Invalid Password. Try Again.");
}
}
}