Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement