Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Try/Catch create a program that prompts the user to create a name and password. This will be like the registration process implements by applications

Java Try/Catch

create a program that prompts the user to create a name and password. This will be like the registration process implements by applications and websites that utilize a log in system. The program will validate the user's input and make sure it meets the context requirements. A try/catch system will be used to deal with any invalid input.

The username must be all letters with an allowance for one space. No numbers, symbols or ogler characters are permitted. Use methods from lava. Character class such as isLetter() to parse the users input in a for loop. If an invalid character is found in the input string, throw an exception object from your own custom Exception class. (more on that below)

The password must have at least 1 uppercase, 1 lowercase, 1 number and 1 symbol. It must also be at least 6 characters long. Use Character methods like isUpperCase() and isLetterOrDigit() to verify that this criteria is met. You may use the same Exception class as above or create a separate one just for handling password exceptions. It can be done either way.

The Exception class(es) will need a constructor that receives the details for why the exception was thrown. This may include the user's input and the character or index of the character that did not meet the specification. Override the toString() method to return a string with the information in a labeled, professional format. Program will display this string from catch blocks.

In main() prompt the user for the name and the password 2 separate do loops. If an exception is thrown the program will display the error and immediately prompt the user for the name or password.

//

//Example

Output may look something like this:

Enter name: Fred Fl0p

Error: Username must contain only letters and up to I space.

Found: 0

Enter name: Fred Flop

Create a password: Pas$w0rd

Great password Fred Flop, welcome to the system.

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Define safety and health.

Answered: 1 week ago