Question
This is done in Java. I finished my code. I just need the Demo class. Here is the question: Imagine you are developing a software
This is done in Java. I finished my code. I just need the Demo class.
Here is the question:
Imagine you are developing a software package for Amazon.com 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 another program that allows the user to enter a password and then displays a message indicating whether it is valid or not.
TIP: You will have two Java programs, one is definition, PasswordVerifier.java for instance, another one is demo, PasswordDemo.java for instance. In your PasswordVerifier.java program you will have to define methods, for example, hasUpperCase(), hasLowerCase(), hasDigit(), and isLongerThenSix() to verify the above mentioned criteria. In your PasswordDemo.java program, you will ask the user to input a password, then call each method defined in PasswordVerifier.java to check if the customer entered password is valid.
Here is my code:
import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
/** * * @author */ public class PasswordVerifier { public static void main(String[] args){ String input; //holds input boolean hasUpperLetters = false; boolean hasLowerLetters = false; boolean hasDigits = false; boolean hasSomethingElse = false; //Creating the Scanner for the keyboard Scanner keyboard = new Scanner(System.in); //Get the password System.out.print("Please enter a password: "); input = keyboard.nextLine(); int passLength = input.length(); //Loop will repeat for all characters in the string for (int i=0; i < passLength; i++) { char c = input.charAt(i); //Check for one or moore Upper case letter if(Character.isUpperCase(c)) hasUpperLetters = true; //Check for one or more Lower case letter else if (Character.isLowerCase (c)) hasLowerLetters = true; //Check for one or more digit else if (Character.isDigit (c)) hasDigits = true; else hasSomethingElse = true; } //Condition checking for verified password if (hasUpperLetters && hasDigits && hasLowerLetters && !hasSomethingElse && (passLength >= 6))
{ System.out.println("Your password is formatted correctly"); } else { System.out.println("Your password is not formatted correctly"); } } }
All I need is the PasswordDemo.java
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started