10/25/11



Simple Password in Java

10/25/2011


CODE:




import javax.swing.JOptionPane;


public class Password{


public static void main(String[] args){

String myPassword = "bhebko";
int countOfTries = 0;

do{
String password = JOptionPane.showInputDialog(null, "Enter password: ", "Input",JOptionPane.INFORMATION_MESSAGE);
if(password.equals(myPassword)){
JOptionPane.showMessageDialog(null, "Correct password.", "Information", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
else{
JOptionPane.showMessageDialog(null, "Incorrect password.", "Information", JOptionPane.ERROR_MESSAGE);
countOfTries++;
}
}while(countOfTries!=3);
JOptionPane.showMessageDialog(null, "You have reach the maximum retries.", "Now exiting...", JOptionPane.INFORMATION_MESSAGE);
}



}






SAMPLE OUTPUT:











Your thoughts about this post? Leave a commment now.

Posted by

AndyFGo : A place for Pinoy Music News. Lyrics. Music Videos. Pinoy Movie/Foreign Trailers. OPM.

 

© 2013 andyfgo. All rights reserved. Designed by Templateism. Powered by Blogger
Protected by Copyscape DMCA Takedown Notice Violation Search

Back To Top