Question

In: Computer Science

•Write a JAVA program to check a given password strength from a user's input. •Create a...

•Write a JAVA program to check a given password strength from a user's input.

•Create a method to check the number of characters. It must be more than 8.

•Create a method to check the password to have at least one uppercase letter.

•Create a method to check the password to have at least one lowercase letter.

•Create a method to check the password to have at least one digit.

•Create a method to check the password to have at least one special character (!, 2, #, %, &, *, (, ), etc.)

•Create a method called isValid to check if the password is valid.

Solutions

Expert Solution

import java.util.Scanner;

public class PasswordValidator {

        public static void main(String[] args) {
                Scanner input = new Scanner(System.in);
                        System.out.print("Enter a password: ");
                        String s = input.nextLine();
                        if (isValid(s)) {
                                System.out.println("Valid Password");
                        } else {
                                System.out.println("Invalid Password");
                        }

        }

        public static boolean isValid(String pwd) {
                return checkCharCount(pwd) && checkForDigit(pwd) && checkForSpecial(pwd) && checkForLetter(pwd);
        }

        // checks if password has 8 characters
        public static boolean checkCharCount(String pwd) {
                return pwd.length() >= 8;
        }

        // checks if password has letter
        public static boolean checkForLetter(String pwd) {
                for (int i = 0; i < pwd.length(); i++)
                        if (Character.isLetter(pwd.charAt(i)))
                                return true;
                return false;
        }

        // checks if password contains digit
        public static boolean checkForDigit(String pwd) {
                for (int i = 0; i < pwd.length(); i++)
                        if (Character.isDigit(pwd.charAt(i)))
                                return true;
                return false;
        }

        // checks if password has special char
        public static boolean checkForSpecial(String pwd) {
                String spl = "!@#$%^&*()";
                for (int i = 0; i < pwd.length(); i++)
                        if (spl.contains(pwd.charAt(i) + ""))
                                return true;
                return false;
        }

}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

•Write a JAVA program to check a given password strength from a user's input. •Create a...
•Write a JAVA program to check a given password strength from a user's input. •Create a method to check the number of characters. It must be more than 8. •Create a method to check the password to have at least one uppercase letter. •Create a method to check the password to have at least one lowercase letter. •Create a method to check the password to have at least one digit. •Create a method to check the password to have at...
2. Write a Java program to read a string (a password)from the user and then   check...
2. Write a Java program to read a string (a password)from the user and then   check that the password conforms to the corporate password policy.   The policy is:   1) the password must be at least 8 characters   2) the password must contain at least two upper case letters   3) the password must contain at least one digit   4) the password cannot begin with a digit   Use a for loop to step through the string.   Output “Password OK” if the password...
Write a Java method to check whether a string is a valid password. Password rules: A...
Write a Java method to check whether a string is a valid password. Password rules: A password must have at least ten characters. A password consists of only letters and digits. A password must contain at least two digits. There are at least SIX functions/methods as the following: 1. menu() – to print the password’s rules. 2. getString() – to get the password from the user. 3. isPassword() – to check either the password is valid based on the given...
Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks...
Create a Java application called ValidatePassword to validate a user’s password. Write a program that asks for a password, then asks again to confirm it. If the passwords don’t match or the rules are not fulfilled, prompt again. Your program should include a method that checks whether a password is valid. From that method, call a different method to validate the uppercase, lowercase, and digit requirements for a valid password. Your program should contain at least four methods in addition...
Write a java program to reverse element of a stack. For any given word (from input),...
Write a java program to reverse element of a stack. For any given word (from input), insert every character (from the word) into a stack. The output from the stack should be the same as the input. Your program should be using a stack and a queue to complete this process. 1. Push into stack 2. Pop from stack 3. Enqueue into queue 4. Dequeue from queue 5. Push into stack 6. Pop from stack and display java
Write a Java program to create an array of a specific size (which is an input...
Write a Java program to create an array of a specific size (which is an input from the user) and fill it with random numbers between 1 and 100. Then sort the array and count how many of these numbers are originally at sorted position. Display that original array, the sorted array, and the count (number of elements originally at sorted position).
C++ Read first a user's given name followed by the user's age from standard input. Then...
C++ Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata (which you must declare) to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.
2. Write a Java program that reads a series of input lines from given file “name.txt”,...
2. Write a Java program that reads a series of input lines from given file “name.txt”, and sorts them into alphabetical order, ignoring the case of words. The program should use the merge sort algorithm so that it efficiently sorts a large file. Contents of names.text Slater, KendallLavery, RyanChandler, Arabella "Babe"Chandler, StuartKane, EricaChandler, Adam JrSlater, ZachMontgomery, JacksonChandler, KrystalMartin, JamesMontgomery, BiancaCortlandt, PalmerDevane, AidanMadden, JoshHayward, DavidLavery,k JonathanSmythe, GreenleeCortlandt, OpalMcDermott, AnnieHenry, DiGrey, MariaEnglish, BrookeKeefer, JuliaMartin, JosephMontgomery, LilyDillon, AmandaColby, LizaStone, Mary FrancesChandler, ColbyFrye, DerekMontgomery,...
write a java program to Translate or Encrypt the given string : (input char is all...
write a java program to Translate or Encrypt the given string : (input char is all in capital letters) { 15 } *) Each character replaced by new character based on its position value in english alphabet. As A is position is 1, and Z is position 26. *) New characters will be formed after skipping the N (position value MOD 10) char forward. A->A+1= B , B->B+2=D ,C->C+3=F, .... Y->Y+(25%10)->Y+5=D A B C D E F G H I...
Write a program(C#) that prompts the user for her home planet. Based on the user's input...
Write a program(C#) that prompts the user for her home planet. Based on the user's input the program will display the following: Input: earth Message: earth. You are an Earthling and you have 10 fingers Input: VENUS Message: VENUS. You are a Venusian and you have 12 fingers Input: Mars Message: Mars. You are a Martian and you have 8 fingers any other input Message: I am sorry I don't know of that planet You may use either the ToUpper()...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT