Results 1 to 2 of 2
  1. #1
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default Help with password matches

    I want it to output "Wrong ID" If only the password matches "open" and output "Wrong Password" If only the user ID matches "admin."
    How do i do it?

    Java Code:
    import javax.swing.JOptionPane;
    import java.lang.*;
    
    public class Logpass
    {
    public static void main(String [ ] args)
    {
    char ID;
    char password;
    
    String input1 = JOptionPane.showInputDialog(null, "Please enter your ID.");
    String input2 = JOptionPane.showInputDialog(null, "Please enter youe password.");
    
    if( input1.equals( "admin" ) && input2.equals( "open" ))
    {
    JOptionPane.showMessageDialog(null, "Welcome");
    }
    else if( )
    {
    JOptionPane.showMessageDialog(null, "Wrong ID");
    }
    else if( )
    {
    JOptionPane.showMessageDialog(null, "Wrong password");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Wrong ID and Password");
    }
    }
    }
    Thanks
    Albert:rolleyes:

  2. #2
    olatunbode is offline Member
    Join Date
    Jul 2007
    Posts
    5
    Rep Power
    0

    Default

    Java Code:
    //first of all, you dont need to import the java.lang package
    //it is imported automatically
    
    import javax.swing.JOptionPane;
    
    public class Correction{
    
       public static void main(String[] args)
       {
    
          String input1 = JOptionPane.showInputDialog(null, "Please enter your ID.");
          String input2 = JOptionPane.showInputDialog(null, "Please enter your password.");
    
          if(input1.equals("admin") && input2.equals("open")){
             JOptionPane.showMessageDialog(null, "Welcome");
          }
          else if(input1.equals("admin") && input2.equals("")){
             JOptionPane.showMessageDialog(null, "Wrong Password");
          }
          else if(input1.equals("") && input2.equals("open")){
             JOptionPane.showMessageDialog(null, "Wrong ID");
          }
          else{
             JOptionPane.showMessageDialog(null, "Wrong ID and Password");
          }
    
          System.exit(0);
       }
    }
    Last edited by JavaBean; 07-10-2007 at 04:33 PM.

Similar Threads

  1. Password System help
    By quickfingers in forum New To Java
    Replies: 1
    Last Post: 06-23-2008, 06:18 PM
  2. Change Password Functionality
    By Priyadharshini.s in forum Advanced Java
    Replies: 5
    Last Post: 04-02-2008, 12:56 PM
  3. Asking for password from a Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-27-2008, 08:05 PM
  4. add password to folder
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-08-2008, 05:46 AM
  5. Problem with a password
    By saytri in forum New To Java
    Replies: 2
    Last Post: 12-27-2007, 11:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •