Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class UserInputNested {
- public static void main(String[] args) {
- String Username = JOptionPane.showInputDialog("Username: "); //Sets the variable Username to the input that user types.
- if (
- (Username != null) && //Checks to see if user types something
- (Username.equals("Sabih")) //And if user types Sabih
- ) {
- String Password = JOptionPane.showInputDialog("Password: ");
- if (Password.equals("Hasan")) {
- JOptionPane.showMessageDialog
- (null, "You now have access to the System", "System Access", JOptionPane.INFORMATION_MESSAGE);
- } else {
- JOptionPane.showMessageDialog
- (null, "Incorrect Password", "Password", JOptionPane.ERROR_MESSAGE);
- }
- } else { //If user does not type Sabih
- JOptionPane.showMessageDialog
- (null, "Username can't be identified", "Username", JOptionPane.ERROR_MESSAGE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement