Is anyone here pretty experienced with java? I'm having some issues with this weeks program assignment and would love some help.
Thanks!
Need help w/ java class
-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
-
Waffles
- Posts: 6876
- Joined: Mon Dec 11, 2006 3:45 am
Need help w/ java class
Its been a while since I programmed in java, but post it up and I will see what i can do.

-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
Thanks like I said any help is appreciated. This is what the teacher put for us to program for.
Main Method
Implement a program that reads in a user password and verifies it meets the following criteria:
• Is atleast 8 characters long
• Contains atleast 1 lower letter character
• Contains atleast 1 upper letter character
• Contains atleast 1 numeric digit
• Contains atleast 1 special character from the set: !@#$%^&*
• Does not contain the word “and” or the word “end”
Output a string that prompts the user for a password and include the requirements above in your output.
Output a string that states valid or invalid. If invalid, state which rule above has not been met.
Utilize the following functionality:
• indexOf
• Looping structure
• charAt()
• isDigit()
• isUpperCase()
• isLowerCase()
• and any additional functionality needed.
Sample Output:
Password Verifier
Enter a password that meets the following rules:
Password1
Invalid
Missing a special character
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Panda123$
Invalid
Contains the string “and”
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Hi
Invalid
Must be at least 8 characters long
Must contain a numeric digit
Must contain a special character
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Pa$$word1
Valid
I have a partial program done already and emailed it to the teacher for help but not sure how much help he'll give me.
From what he said its pretty simple but I just dont see it.
Thanks!
Main Method
Implement a program that reads in a user password and verifies it meets the following criteria:
• Is atleast 8 characters long
• Contains atleast 1 lower letter character
• Contains atleast 1 upper letter character
• Contains atleast 1 numeric digit
• Contains atleast 1 special character from the set: !@#$%^&*
• Does not contain the word “and” or the word “end”
Output a string that prompts the user for a password and include the requirements above in your output.
Output a string that states valid or invalid. If invalid, state which rule above has not been met.
Utilize the following functionality:
• indexOf
• Looping structure
• charAt()
• isDigit()
• isUpperCase()
• isLowerCase()
• and any additional functionality needed.
Sample Output:
Password Verifier
Enter a password that meets the following rules:
Password1
Invalid
Missing a special character
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Panda123$
Invalid
Contains the string “and”
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Hi
Invalid
Must be at least 8 characters long
Must contain a numeric digit
Must contain a special character
-----------------------------------------------------------------
Password Verifier
Enter a password that meets the following rules:
Pa$$word1
Valid
I have a partial program done already and emailed it to the teacher for help but not sure how much help he'll give me.
From what he said its pretty simple but I just dont see it.
Thanks!
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
-
Waffles
- Posts: 6876
- Joined: Mon Dec 11, 2006 3:45 am
Need help w/ java class
Where are you getting stuck. I don't want to do the whole assignment, just help.

-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
Im getting stuck where you need to implement the indexOf for making sure the words 'end' and 'and' aren't used. And I'm still unsure about how to have the program display which contraints are still not met, shown in that example output.Waffles;296936 wrote:Where are you getting stuck. I don't want to do the whole assignment, just help.
This is what I currently have....
------------------------------------------------------------------------
import java.util.Scanner;
public class RunyonDavidProg5
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter a password that meets the following rules: ");
System.out.println("\tIs atleast 8 characters long");
System.out.println("\tContains atleast 1 lower letter character");
System.out.println("\tContains atleast 1 upper letter character");
System.out.println("\tContains atleast 1 numeric digit");
System.out.println("\tContains atleast 1 special character from the set: !@#$%^&*");
System.out.println("\tDoes not contain the word 'and' or the word 'end'");
String password = scan.nextLine();
int length = password.length();
int digit = 0;
int lowerCase = 0;
int upperCase = 0;
int count = 0;
char ch;
if(length >= 8)
{
while(count =1 && lowerCase >=1 && upperCase >= 1)
System.out.println("Valid");
else
System.out.println("Invalid");
}
}
-------------------------------------------------------------------------------
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
-
Waffles
- Posts: 6876
- Joined: Mon Dec 11, 2006 3:45 am
Need help w/ java class
Index of is a nice and simple one that will return a number greater than -1 of the search string is found.
My syntax might not be perfect but you should get the idea. If you want to get a little more complex you can put the invalid characters/words into a array and cycle through it in a for loop.
Code: Select all
string strInvalid = "end"
int intInvalid = -1
intInvalid = password.indexOf(strInvalid)
if (intInvalid > -1){
System.out.println("tCant use the word end")}
My syntax might not be perfect but you should get the idea. If you want to get a little more complex you can put the invalid characters/words into a array and cycle through it in a for loop.

-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
awesome thanks, so when it comes to the 'and' do i just put == "and" or a comma or another stringname?Waffles;296953 wrote:Index of is a nice and simple one that will return a number greater than -1 of the search string is found.
Code: Select all
string strInvalid = "end" int intInvalid = -1 intInvalid = password.indexOf(strInvalid) if (intInvalid > -1){ System.out.println("tCant use the word end")}
My syntax might not be perfect but you should get the idea. If you want to get a little more complex you can put the invalid characters/words into a array and cycle through it in a for loop.
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
-
Waffles
- Posts: 6876
- Joined: Mon Dec 11, 2006 3:45 am
Need help w/ java class
I would just re purpose intInvalid to equal "and" and redo the if statement. You could also creat a method since you are reusing the same statement twice. Dont know if you are on to methods yet in your java class.

-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
Its just an Intro to Programming class. My teacher added like two lines of code to mine and it checks for the 'and' or 'end' and will return a -1 and print it but then my Valid statement still shows up. This is a bad week for me to have an assignment I dont get lol.Waffles;296956 wrote:I would just re purpose intInvalid to equal "and" and redo the if statement. You could also creat a method since you are reusing the same statement twice. Dont know if you are on to methods yet in your java class.
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
-
sirricealot
- Posts: 841
- Joined: Sat Feb 19, 2011 3:35 pm
Need help w/ java class
I've got the and/end portion down. I tried doing the same thing for the special characters that are needed but it doesn't work if I put them all into one "!@#$%^&*" . I tried making seperate ones such as "!", "@","#"...... but it threw me an error.
2006 Chevy Cobalt SS/NA 2.4L IL: FEERME7
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon
2010 Kawasaki Ninja 250r IL: RUNYON
xbxlive: sirricealot07
ps3: sirricealot7
David Runyon