Greetings,
I'm completely new to programming and thought I might give java a try.
I'm trying to write a program that gets a password from a user. It will then be tested against a password stored in a string. I want to use a while
loop that will repeat until the user gets the correct password.
When I use an online compiler, it doesn't execute for me. Am I on the right path? The code is as follows...
Thank you for any sugggestions,import javax.swing.JOptionPane; public class Password { public static void main(String[] args) { String yourpass, mypass; mypass = "happy"; boolean b = false; while(!b) { yourpass = JOptionPane.showInputDialog(null, "Enter password: "); if(yourpass.equals(mypass)) { JOptionPane.showMessageDialog(null, "Correct password!"); b = true; } else { JOptionPane.showMessageDialog(null, "Incorrect password!"); } } } }
Jim