Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing this program code in Java. Problem 2 Password Validation (10 pts) Write a program that provides a list of rules (see

I need help writing this program code in Java.

Problem 2 Password Validation (10 pts)

Write a program that provides a list of rules (see sample output) for creating a password. The program will then ask the user for a password to check. If the password entered is valid, an appropriate message will be displayed saying so. If the password is invalid, an appropriate message is shown, plus a statement for each broken rule that made it invalid (see sample output for all messages).

Requirements:

The output of your program must match the sample outputs exactly for each sample input entered. Notice there are five sample outputs to test, each for a different situations. Your program must implement the following static methods:

  1. A method called minLength that returns a boolean value and takes the entered password as a String parameter. The return value will be true if the password contains at least 10 characters, otherwise it will be false.

  2. A method called validChars that returns a boolean value and takes the entered password as a String parameter. The return value will be true if the password contains only letters and numbers and no other characters, otherwise it will be false.

  3. A method called minDigits that returns a boolean value and takes the entered password as a String parameter. The return value will be true if the password contains at least two number digits, otherwise it will be false.

  4. A method called isValid that returns a boolean value and takes the entered password as a String parameter. This method should call methods 1-3 from above, inside its body. The return value will be true if the password passes all three tests (i.e. if methods 1-3 return true when used on the password). Otherwise, the return value will be false.

Your main program should not be complex and must use the required methods listed above as part of your solution. If necessary, review how to write static methods and where to place them in your main class.

Tip: Using ASCII character conversion may come in handy.

Sample outputs.

image text in transcribed

image text in transcribed

image text in transcribed

Sample Output #1: run: Password Rules: 1. Must contain at least 10 characters 2. Only letters and numbers allowed 3. Must contain at least 2 digits Please enter a password to check pass word 13 Sorry, your password is invalid for the following reasons: -Password contains invalid characters. BUILD SUCCESSFUL (total time: 7 minutes 38 seconds) #2: run: Password Rules: 1. Must contain at least 10 characters. 2. Only letters and numbers allowed 3. Must contain at least 2 digits Please enter a password to check: lovely43 Soxry, your password is invalid for the following reasons: -Password is too short BUILD SUCCESSFUL (total time: 9 seconds) #3: run: Password Rules: 1. Must contain at least 10 characters. 2. Only letters and numbers allowed. 3. Must contain at least 2 digits Please enter a password to chec: longenough7 Sorry, your password is invalid for the following reasons: Password does not have at least two digits BUILD SUCCESSFUL (total time: 15 seconds)

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions