Ceate a program that generates a random password


Assignment

Many applications impose rules for user passwords. Write a program that utilizes methods to check a user entered password ***** print out either "Valid" or "Invalid", based on the following rules:

• Password ***** be at least 5 characters long, but no longer than 8 characters (in other words, valid password ***** is in the range: 5<=len<=8)

• Password ***** consists of only letters (upper or lower case, or some combination of upper and lower), digits, and special characters from the following set: !@#$%^&* (note: not every special character and punctuation mark is in this set. These characters correspond to Shift+1 through Shift+8 on the keyboard)

• Password ***** contain at least one digit, at least one letter, and at least one special character from the set defined in the point above.

Requirement: your program must include methods to perform these checks. Programs that do not use methods will not receive credit even if they function correctly.

Input: Prompt the user to enter a password.

Output: If the password ***** one or more of the rules, print out "Invalid", if it does not, print out "Valid".

Sample 1:

Please enter a password: A!2g

Invalid

Sample 2:

Please enter a password: A!2gt9

Valid

Sample 3:

Please enter a password: mnkys5

Invalid

Sample 4:

Please enter a password: mnkys5&

Valid

2) Create a program that generates a random password ***** user-defined length. For the purposes of this problem, we will assume that any character that corresponds to ASCII (decimal) values in the range 33-126 is a valid password ***** Hint: use the integer-character correspondence (generate random integers between 33 and 126, then convert them to characters).

Requirement: your program must include a method that generates and returns one random character. This method should be called some (user-specified) number of times by a loop that will use the returned characters to "build" the password ***** Programs that do not include this method will not receive credit even if they function correctly.

Input: Prompt the user to enter the length of the password ***** is to be generated by your program.

Output: A randomly-generated password ***** user-specified length.

Sample 1:

Please enter password *****: 3

Password: h3*

Sample 2:

Please enter password *****: 8

Password: bT7@y)w+

3) Write a method that displays an n-by-n matrix using the following header: public static void printMatrix(int n)

Each element in the matrix is either a 0 or a 1, generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix of zeroes and ones.

Requirement: Your program must includ the method defined above. Programs that do not include it will not receive credit, even if they function correctly.

Sample run:

Enter n: 3

0 1 0

0 0 0

1 0 1

Solution Preview :

Prepared by a verified Expert
Programming Languages: Ceate a program that generates a random password
Reference No:- TGS01710977

Now Priced at $40 (50% Discount)

Recommended (95%)

Rated (4.7/5)