SHARE
TWEET

Untitled

a guest Sep 24th, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.JOptionPane;
  2.  
  3. public class UserInputNested {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         String Username = JOptionPane.showInputDialog("Username: "); //Sets the variable Username to the input that user types.
  8.        
  9.         if (
  10.             (Username != null) && //Checks to see if user types something
  11.             (Username.equals("Sabih")) //And if user types Sabih
  12.            ) {
  13.             String Password = JOptionPane.showInputDialog("Password: ");
  14.            
  15.             if (Password.equals("Hasan")) {
  16.                 JOptionPane.showMessageDialog
  17.                 (null, "You now have access to the System", "System Access", JOptionPane.INFORMATION_MESSAGE);
  18.             } else {
  19.                 JOptionPane.showMessageDialog
  20.                 (null, "Incorrect Password", "Password", JOptionPane.ERROR_MESSAGE);
  21.             }
  22.                    
  23.                
  24.         } else { //If user does not type Sabih
  25.             JOptionPane.showMessageDialog
  26.             (null, "Username can't be identified", "Username", JOptionPane.ERROR_MESSAGE);
  27.            
  28.         }
  29.              
  30.     }
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top