Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2007, 08:46 PM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
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?

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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-10-2007, 06:17 PM
Member
 
Join Date: Jul 2007
Posts: 5
olatunbode is on a distinguished road
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 06:33 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password System help quickfingers New To Java 1 06-23-2008 08:18 PM
Change Password Functionality Priyadharshini.s Advanced Java 5 04-02-2008 02:56 PM
Asking for password from a Servlet Java Tip Java Tips 0 01-27-2008 10:05 PM
add password to folder ismailsaleh AWT / Swing 1 01-08-2008 07:46 AM
Problem with a password saytri New To Java 2 12-27-2007 01:06 PM


All times are GMT +3. The time now is 12:15 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org