Question

In: Computer Science

You are developing a software package for an online shopping site that requires users to enter...

You are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria:

● The password should be at least six characters long.
● The password should contain at least one uppercase and at least one
lowercase letter.
● The password should have at least one digit.

Write a method that verifies that a password meets the stated criteria. Use this method in a program that allows the user to enter a password and then determines whether or not it is a valid password. If it is valid, have the program print "Valid Password". Otherwise, it should print "Invalid Password".

Sample Run
java PasswordVerifier

Enter·password·to·be·verified:ComputerScience4Life↵
Valid·password

Solutions

Expert Solution

import java.util.Scanner;

public class PasswordVerifier {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                System.out.print("Enter password to be verified: ");
                String password = sc.nextLine();
                if (validPassword(password))
                        System.out.println("Valid password");
                else
                        System.out.println("Invalid password");
        }

        public static boolean validPassword(String pwd) {
                return checkLength(pwd) && hasUppercase(pwd) && hasLowerCase(pwd) && hasDigits(pwd);

        }

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

        public static boolean hasLowerCase(String pwd) {
                for (int i = 0; i < pwd.length(); i++)
                        if (Character.isLetter(pwd.charAt(i)) && Character.isLowerCase(pwd.charAt(i)))
                                return true;
                return false;
        }

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

        public static boolean checkLength(String s) {
                return s.length() >= 6;
        }
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

Please Like and Support me as it helps me a lot


Related Solutions

You are developing a software package for an online shopping site that requires users to enter...
You are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria: ● The password should be at least six characters long. ● The password should contain at least one uppercase and at least one lowercase letter. ● The password should have at least one digit. Write a method that verifies that a password meets the stated criteria. Use this method in a...
Imagine you are developing a software package for an online shopping site that requires users to...
Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a class that verifies that a password meets the stated criteria. Demonstrate the class in a program that...
Imagine you are developing a software package that requires users to enter their own passwords. Your...
Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria: The password should be at least six characters long. The password should be at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a program that asks for a password then verifies that it meets the stated criteria. If it doesn't, the program should display a...
Imagine you are developing a software package that requires users to enter their own passwords. Your...
Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that user’s passwords meet the following criteria: 1. The password should be at least six characters long. 2. The password should contain at least one uppercase and at least one lowercase letter. 3. The password should have at least one digit. Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn’t, the...
Early in 2021, the Excalibur Company began developing a new software package to be marketed. The...
Early in 2021, the Excalibur Company began developing a new software package to be marketed. The project was completed in December 2021 at a cost of $102 million. Of this amount, $68 million was spent before technological feasibility was established. Excalibur expects a useful life of five years for the new product with total revenues of $170 million. During 2022, revenue of $51 million was recognized. Required: 1. Prepare a journal entry to record the 2021 development costs. 2. Calculate...
You are asked to review a nominal scale that identifies users versus non-users of an online...
You are asked to review a nominal scale that identifies users versus non-users of an online journal for primary school pupils. What is the most appropriate measure of central tendency? a. Range b. Mean c. Mode d. Median
You are off to shopping and need a program that allows you to enter the names...
You are off to shopping and need a program that allows you to enter the names of items, their price and quantities. Here is what a sample run should look like (with the keyboard input shown in italics) ... Enter item information ("exit" to exit) item 1: chips price: 3.5 quantity: 2 Enter item information ("exit" to exit) item 2: red wine price : 15.0 quantity : 1 Enter item information ("exit" to exit) item 3 : steaks price :...
This week you will write a program that mimics an online shopping cart . You will...
This week you will write a program that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers for quantities -...
Developing software programs requires a systematic approach to problem solving and involves several steps. For a...
Developing software programs requires a systematic approach to problem solving and involves several steps. For a given problem statement – assuming the problem has a software solution – list and describe in your own words the steps that enable you to bring the software solution to life.
Software Engineering: Details: Title: Online Medicine Shopping Website Source: Internet 1. Admin Module: Admin need to...
Software Engineering: Details: Title: Online Medicine Shopping Website Source: Internet 1. Admin Module: Admin need to login by providing the login credentials to access the below given admin modules.a. Product Entry: Admin can enter details about new medicine products details.b. View Order: Admin can view details about the order placed by the user.c. View Users Details: Admin can view all the registered user’s details. 2. User Module: User can register on the system and get his/her online account on site.a....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT