Question: import java.util.Scanner; /** * Chapter 8 * Programming Challenge 5: Password Verifier * This program demonstrates the PasswordVerifier class. */ public class PasswordDemo { public

import java.util.Scanner; /** * Chapter 8 * Programming Challenge 5: Password Verifier * This program demonstrates the PasswordVerifier class. */ public class PasswordDemo { public static void main(String[] args) { String input; // To hold input // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Get a password. System.out.print("Enter a password: "); input = keyboard.nextLine(); // Check the password. if (!PasswordVerifier.isValid(input)) System.out.println("Invalid password."); else System.out.println("Valid password."); } }

Second Code- Different Class

/** * Chapter 8 * Programming Challenge 5: Password Verifier * The PasswordVerifier class stores data about * a user's password. */ public class PasswordVerifier { // Constant for minimum password length public static final int MIN_PASSWORD_LENGTH = 6; /** * isValid method */ public static boolean isValid(String str) { boolean status; // Validity status if (str.length() >= MIN_PASSWORD_LENGTH && hasUpperCase(str) && hasLowerCase(str) && hasDigit(str)) status = true; else status = false; return status; } /** * hasUpperCase method */ private static boolean hasUpperCase(String str) { //insert code here } /** * hasLowerCase method */ private static boolean hasLowerCase(String str) { //insert code here } /** * hasDigit method */ private static boolean hasDigit(String str) { //insert code here } }

Advanced Java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!