Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Requirement-2 (20 pts): (a) Write a program called UserSetup that sets up the password for an existing user. This program will first ask the

JAVA

Requirement-2 (20 pts): (a) Write a program called UserSetup that sets up the password for an existing user. This program will first ask the user to enter a username, with the message Welcome to the User Account & Password Setup. Please enter your username. Use the while or do-while loop to continuously ask the user to re-enter username until a non-empty string is entered by the user. (b) Upon receiving the username with a non-zero length, your program should call the method validateUsername, which takes in a string object as parameter. The method should do the following: (i) Match the username entered with one of the following 4 names only - John - Angel - Peter - Samantha In other words, if the user enters any other user name, the username validation should fail. This validation needs to be case-sensitive. For example, comparison of John and john should fail (return false) (ii) Print the following message if the attempt to match with any of the 4 names listed above fails No user found with name: username Please try again (iii) After 3rd failed attempt to match, the program should exit, with the message: No user found with name: username Please try again later. Goodbye (iv) Upon successful match of username, ask user to enter password and print the following rules for a valid password, for users reference, with the message: Rules for a valid password are: Rule1: Should be 8-10 characters long Rule2: Should contain only alphanumeric characters Rule3: Should contain at least 2 numbers Rule4: Should contain at least 1 uppercase character (v) Use the do-while loop to continuously ask the user to re-enter password if a non-empty password string is entered. Upon receiving the password, your program should call the method validatePassword, which takes in a string object as parameter, and

validates the password based on the above mentioned password validation rules (vi) If the password entered passes all 4 validation rules, print the following message and exit the program: Password successfully set for user: username Goodbye. (vii) If the password entered fails validation check, ask user to reenter password. After 3rd failed attempt, print the following message and exit the program: Attempt to set password failed for: username. Please try again later. Goodbye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions