Results 1 to 2 of 2
Thread: Help with password matches
- 07-09-2007, 07:46 PM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 114
- Rep Power
- 0
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"); } } }
Albert:rolleyes:
- 07-10-2007, 05:17 PM #2
Member
- Join Date
- Jul 2007
- Posts
- 5
- Rep Power
- 0
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 05:33 PM.
Similar Threads
-
Password System help
By quickfingers in forum New To JavaReplies: 1Last Post: 06-23-2008, 07:18 PM -
Change Password Functionality
By Priyadharshini.s in forum Advanced JavaReplies: 5Last Post: 04-02-2008, 01:56 PM -
Asking for password from a Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-27-2008, 09:05 PM -
add password to folder
By ismailsaleh in forum AWT / SwingReplies: 1Last Post: 01-08-2008, 06:46 AM -
Problem with a password
By saytri in forum New To JavaReplies: 2Last Post: 12-27-2007, 12:06 PM
Bookmarks