Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Main Method Implement a program that reads in a user password and verifies it me

ID: 3629419 • Letter: M

Question

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:
<list rules from above>
Password1

Invalid
Missing a special character

-----------------------------------------------------------------

Password Verifier

Enter a password that meets the following rules:
<list rules from above>
Panda123$

Invalid
Contains the string “and”

-----------------------------------------------------------------

Password Verifier

Enter a password that meets the following rules:
<list rules from above>
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:
<list rules from above>
Pa$$word1

Valid

Explanation / Answer

please rate - thanks

import java.util.Scanner;
public class ValidPassword
{
public static void main (String[] args)
{String word;
boolean a,b,c,d,e,f;
Scanner input = new Scanner(System.in);
System.out.println("Password Verifier");
System.out.println("Enter a password that meets the following rules:");
System.out.println("Is at least 8 characters long");
System.out.println("Contains at least 1 lower letter character");
System.out.println("Contains at least 1 upper letter character");
System.out.println("Contains at least 1 numeric digit");
System.out.println("Contains at least 1 special character from the set: !@#$%^&*");
System.out.println("Does not contain the word "and" or the word "end"");
word=input.next();
a=len(word);
b=upper(word);
c=lower(word);
d=number(word);
e=special(word);
f=good(word);
if (a && b && c && d && e && f)
         System.out.println("valid password");
else
         printReason(a,b,c,d,e,f,word);
}
public static void printReason(boolean a,boolean b,boolean c,boolean d, boolean e, boolean f,String s)
{System.out.println("invalid password");
if(!a)
   System.out.println("Must be at least 8 characters long");
if(!b)
   System.out.println("Must contain a upper case letter");
if(!c)
   System.out.println("Must contain a lower case letter");   
if(!d)
   System.out.println("Must contain a numeric digit");
if(!e)
   System.out.println("Must contain a special character");
if(!f)
   {if(s.indexOf("end")!=-1)
             System.out.println("Contains the string "end"");
       if(s.indexOf("and")!=-1)
              System.out.println("Contains the string "and"");
   }
}
public static boolean len(String s)
   {int i;
    if(s.length()>=8)
         return true;
    return false;
       
   }

public static boolean upper(String s)
   {int i;
    for(i=0;i<s.length();i++)
      if (Character.isUpperCase(s.charAt(i)))
            return true;
      return false;
   }

public static boolean lower(String s)
   {int i;
    for(i=0;i<s.length();i++)
      if (Character.isLowerCase(s.charAt(i)))
            return true;
      
      return false;
   }
public static boolean number(String s)
   {int i;
    for(i=0;i<s.length();i++)
      if (Character.isDigit(s.charAt(i)))
            return true;
          
      return false;
}
public static boolean special(String s)
   {int i,sum=0;
    String specials="!@#$%^&*";
    for(i=0;i<specials.length();i++)
      sum+=s.indexOf(specials.charAt(i));
     if(sum!=specials.length()*-1)
         return true;
        
      return false;
   }
public static boolean good(String s)
   {if(s.indexOf("end")==-1&&s.indexOf("and")==-1)
               return true;
  
      return false;
}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote