Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

=+24. Pope Francis media coverage. The election of Argentine

Answered: 1 week ago