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

This program checks the strengh of a user entered password. Define a variable na

ID: 3762239 • Letter: T

Question

This program checks the strengh of a user entered password.

Define a variable named score and set it to zero.

Add 1 to score if password length is between six and eight, inclusive. Add 2 to score if password length is greater than eight.

Add 1 to score if password contains at least one uppercase character, but only if it is not the first character of the password.

Add 1 to score if password contains at least one lowercase character.

Add 1 to score if password contains at least one digit character.

Add 1 to score if password contains at least one punctuation character. Add another 1 to score if at least two punctuation characters are used that are numerically contained in different intervals of the Unicode character set. {ASCII Chart}

Subtract 5 from score if the password is any of the following "most-used" passwords or their reverse. {ZDnet.com::25 most-used passwords revealed} Note: Case should be ignored when comparing user entered password with the "most-used" passwords (or their reverse).

If not a "most-used" password (or their reverse), then subtract 4 from score if the password contains a "most-used" password (or their reverse).

Print the value of the score variable prior to exiting the program.

Important Rules and Regulations

Input to the program must be read directly from the standard input stream using the System.in object.

A char[] must be used to store the input.

Character constants must be used instead of their Unicode numeric equivalent (e.g. 'A' instead of 65).

And the following...

Explanation / Answer

import java.util.Scanner;
public class MyPassword {
   @SuppressWarnings("unused")
   private static Scanner scanner;
   @SuppressWarnings("unused")
   private static int score;

   @SuppressWarnings("resource")
   public static void main(String str[])
   {
       score = 0;
       String password;
       Scanner sca;
       scanner = sca=new Scanner(System.in);
       System.out.println("Enter the password");
       password=sca.next();
       if(password.length()>=6 && password.length()<=8)
           score++;
       else if(password.length()>8)
           score+=2;
       for(int i=1;i<password.length();i++)
       {
           if(password.charAt(i)>='A' && password.charAt(i)<='Z')
           {
               score++;
               break;
           }
       }
       for(int i=0;i<password.length();i++)
       {
           if(password.charAt(i)>='a' && password.charAt(i)<='z')
           {
               score++;
               break;
           }
       }
       for(int i=0;i<password.length();i++)
       {
           if(password.charAt(i)>='0' && password.charAt(i)<='9')
           {
               score++;
               break;
           }
       }
       for(int i=0;i<password.length();i++)
       {
           if((password.charAt(i)>='!' && password.charAt(i)<='/') || (password.charAt(i)>=':' && password.charAt(i)<='@') || (password.charAt(i)>='[' && password.charAt(i)<='`' || (password.charAt(i)>='{' && password.charAt(i)<='~')))
           {
               score++;
               break;
           }
          
       }
       System.out.println(score);
      
   }
}

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