473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Need Help with Password Program

Hi.
I need a application where accept user password. The java program should do the following:

1. Application accept user password from keyboard
2. It has to be Less than six character and not more than ten character.
3.or it shouldnt contain at one least one letter and one digit
4. User enter password and re-enter password again to meet the requirement.
5.Password has to be matched when user entered 1st and 2nd time.

if any of you have idea about this program please contact me i need urgently this program.

thank u
Nov 15 '06 #1
3 1704
Notepad work, not tested at all...
Using regular expressions might (and most likely will) be a more elegant solution...

Call the method below with the two passwords entered by the user...

Expand|Select|Wrap|Line Numbers
  1. public boolean isPasswordOk( String password1, String password2 ) {
  2.     if(!password1.equals(password2))
  3.         return false;
  4.  
  5.     if(password1.length() < 6 || password1.length() > 10 )
  6.         return false;
  7.  
  8.     char[] c = password1.toCharArray();
  9.     boolean numericOk = false;
  10.     boolean letterOk = false;
  11.     for(int i=0;i<c.length;i++) {
  12.         if(c[i].isDigit() && numericOk = false)
  13.             numericOk = true;
  14.         if(c[i].isLetter() && letterOk = false)
  15.             letterOk = true;        
  16.  
  17.         if( letterOk && numericOk )
  18.             return true;
  19.     }
  20.     return false;
  21. }
Nov 15 '06 #2
Missed something :)
Expand|Select|Wrap|Line Numbers
  1. public boolean isPasswordOk( String password1, String password2 ) {
  2.     if(!password1.equals(password2))
  3.         return false;
  4.  
  5.     if(password1.length() < 6 || password1.length() > 10 )
  6.         return false;
  7.  
  8.     char[] c = password1.toCharArray();
  9.     boolean numericOk = false;
  10.     boolean letterOk = false;
  11.     for(int i=0;i<c.length;i++) {
  12.                 Character char = new Character(c);
  13.         if(char.isDigit() && numericOk = false)
  14.             numericOk = true;
  15.  
  16.         if(char.isLetter() && letterOk = false)
  17.             letterOk = true;        
  18.  
  19.         if( letterOk && numericOk )
  20.             return true;
  21.     }
  22.     return false;
  23. }
  24.  
Still not tested though
Have no IDE and SDK here :)
Nov 15 '06 #3
could you please write me full program i want to whether its great or wrong. i have run the program you have told me but it didnt work.
Nov 15 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Nathan Pinno | last post by:
Hi all, I need help figuring out how to fix my code. I'm using Python 2.2.3, and it keeps telling me invalid syntax in the if name == "Nathan" line. Here is the code if you need it. #This...
15
by: carr4895 | last post by:
Hello. I was wondering if someone could help me too with a login form. Upon startup, I have to display a password screen and it should accept a user name and password. User name can be anything...
9
by: kwindham | last post by:
This program doesn't seem like it should be too hard, but I cannot figure it out. Here is the assignment: Password Verifier - Write a program to verify passwords, satisfying the following...
9
by: ad | last post by:
I used login Controls of VS2005 to develop Web application. My program will check password and user ID in login.aspx. If the password is wrong, my program will display an "password is wrong"...
1
by: karizmatrix22 | last post by:
Hi, I need a programmer who can write 3 programs for following questions below.Programs need to be ready before nextweek.thank you. Person who help me these 3 questions will be get paid.. I am...
3
dfound
by: dfound | last post by:
#include<windows.h> #include<dos.h> #include<dir.h> #include<fstream.h> #include<stdio.h> #include<process.h> #include"resource.h" //resource header file
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
3
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.