Thomas
2013-04-21 16:33:34 UTC
Also if there is other stuff wrong please let me know. =D
This is the part with the error int for(int i=0; i >= 8; i++)
here is the whole thing
import java.util.Scanner;
public class CurranThomasProg5
{
public static void main(String args[])
{ Scanner input = new Scanner(System.in);
System.out.println("Password Verifier\n");
System.out.println("Enter a password that meets the following rules:");
System.out.println("Is at least 8 characters long.");
System.out.println("Contains atleast 1 lower letter character ");
System.out.println("Contains atleast 1 upper letter character ");
System.out.println("Contains atleast 1 numeric digit");
System.out.println("Contains atleast 1 special character from the set: !@#$%^&*");
System.out.println("Does not contain the word \"and\" or the word \"end\"");
String pw = input.nextLine();
boolean oneLower = false; boolean oneUpper = false;
boolean oneNumber = false;
boolean oneSpecial = false;
boolean noAnd = false;
boolean noEnd = false;
int for(int i=0; i >= 8; i++)
{
char c = pw.charAt(i);
if(Character.isLowerCase(c)) oneLower = true;
if(Character.isUpperCase(c)) oneUpper = true;
if(Character.isDigit(c)) oneNumber = true;
if(c == '!' || c=='@' || c=='#' || c=='$' || c=='%' || c=='^' || c=='&' || c=='*') oneSpecial = true;
}
if (pw.indexOf("and") > 0) noAnd = true;
if (pw.indexOf("end") > 0) noEnd = true;
if(oneLower && oneUpper && oneNumber && oneSpecial && noAnd && noEnd && length)
{
System.out.println("Valid");
}
else if (!oneLower)
{
System.out.println("Invalid" + "\n" + "Must contain at least one lowercase character");
}
else if (!oneUpper)
{
System.out.println("Invalid" + "\n" + "Must contain at least one uppercase character");
}
else if (!oneNumber)
{
System.out.println("Invalid" + "\n" + "Must contain at least one digit");
}
else if (!noAnd)
{
System.out.println("Invalid" + "\n" + "Contains the string \"and\"");
}
else if (!oneSpecial)
{
System.out.println("Invalid" + "\n" + "Missing a special character");
}
else if (!noEnd)
{
System.out.println("Invalid" + "\n" + "Contains the string \"end\"");
}
else if (pw.length() < 8)
{
System.out.println("Invalid" + "\n" + "Must contain at least 8 characters");
}
}
}