Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives STARTER CODE INCLUDED. PLEASE HELP AND MAKE SIMPLE AS POSSIBLE THANK YOU By the end of this program, the student will demonstrate the ability

Objectives

STARTER CODE INCLUDED. PLEASE HELP AND MAKE SIMPLE AS POSSIBLE THANK YOU

By the end of this program, the student will demonstrate the ability to

Write static methods

Use methods in a different class

Use loops

Use if/else statements

Use single-dimension arrays

Manipulate Strings

Password Generator

Generate a list of unique passwords. Your program should prompt the user for how many passwords they want to generate, then print the list of passwords. All passwords should follow this pattern:

1. Begin with a random four-letter word. The starter code includes a static method to return a list of valid words.

2. One special character: ! @ # _ . * The starter code includes a static method to return an array of the special characters.

3. A two-digit number: 00-99

4. Five random alphabetic or numeric characters from: abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVEWXYZ0123456789. The starter code includes a method to return these characters as a String

The password rain_23A6vW9 is an example that meets these rules. Your program must include code that checks to see that all passwords are unique.

Complete the Java program PasswordGenerator, which is in the attached zip file. Implement the following methods:

main

Complete the code in the main method so that the program prompts for the number of passwords, then creates and prints the specified number of unique passwords. Refer to the Sample Output below.

(createPassword

Complete the method public static String createPassword(). This method should return a password that meets the rules outlined above. Note that the starter code contains static methods to create four-letter words, special characters, and alphabetic/numeric characters.

isPasswordUnique

Write the method isPasswordUnique(). This method should take 2 parameters: the password to check and a String containing all unique passwords created so far. Return true if the password is unique.

addUniquePassword

Complete the method public static void addUniquePassword(String aPassword, String passwordList). This method will return an updated String containing all unique passwords including aPassword.

Notes:

Hint: The starter code contains 140 unique four-letter words

Hint: You can track the already-generated passwords in a String. Each time you (create a) new password, you can update the String of already-generated passwords

Items in the program that you must complete have a TODO comment

o EX: // TODO: (Complete this) )method

Assume that the user only enters valid input

(Complete this) program in baby steps. There are many ways to approach this program, but whichever order you use, write something then test it immediately. For example, write one method and test it. Then (write) another and test it. And so on. It is better to have something that works, though it's incomplete, than to have something complete that has nothing working.

Grading Elements:

Generated passwords meet the specified rules

Generated passwords use the four-letter words, special characters, and password characters static methods provided in the starter code

All passwords are unique

Specified number of passwords are created

Previously generated passwords are tracked efficiently

Provided method signatures are not changed

Any new methods have appropriate signatures

Sample Output

How many passwords do you want to generate? 10

1: tide*19gH7pd

2: five.57SxJCk

3: rung@65NBTah

4: rote@310W4Yu

5: tide.15RdJKp

6: vile@56tU1Fd

7: five*788BW37

8: rang#24baGa9

9: idle!835MJT6

10: flip@32bICLg

THIS IS THE STARTER CODE:

import java.util.Scanner;

/**

* CSC-151 Spring 2021

*

* @version 2.1

*/

public class PasswordGenerator {

/**

* Special characters

*

* @return Returns n array of chars containing all valid special characters

*/

public static char[] getSpecialCharacters() {

final char[] SPECIAL_CHARS = {'!', '@', '#', '_', '.', '*'};

return SPECIAL_CHARS;

}

/**

* Valid password characters

*

* @return Returns String containing all valid password characters

*/

public static final String getValidPasswordCharacters() {

final String PASSWORD_CHARS = "abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVEWXYZ0123456789";

return PASSWORD_CHARS;

}

/**

* @return Returns a single String of 140 four-letter words than can be used in a password.

*

*/

public static final String getAllFourLetterWords() {

final String FOUR_LETTER_WORDS =

"able bane barn bile blip boat bolt bran brat brim bulb "+

"bull burn cane card cart clan clip cold cone core dart "+

"deny dial dang dirk dolt door dote drip drop dupe each "+

"earn easy fast fest file five flap flip flop foal folk "+

"fort four full gave give gone grin hard hurt idle isle "+

"join king knit knob land lane lard link list live long "+

"lung made main many mile mine moat mole mote mule nine "+

"norm note paid part pick pile ping pipe plan pole pong "+

"port prim pull quid quip quit rain rang redo ring ripe "+

"role root rote rung sand sang silk sing sink slam slow "+

"song sort spam sulk take tame tang tide tile time tint "+

"toll tone took tote trap trip turn undo vile volt vote "+

"wart wing woke wool wore writ zero zoom";

return FOUR_LETTER_WORDS;

}

/**

* (Create a) password

*

* @return Returns a password meeting all of the specifications

*/

public static String createPassword() {

String password = "";

// TODO: (Complete this) method

return password;

}

/**

* Return true if this password is unique to the list of generated passwords.

*/

// TODO: Write the method isUniquePassword.

/**

* Add aPassword to the list of unique passwords

*

* @param aPassword: the password to add

* @param passwordList: A string containing all unique passwords, separated by spaces

* @return Updated passwordList with the new password

*/

public static String addUniquePassword(String aPassword, String passwordList) {

// TODO: (Complete this) method

return "";

}

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("How many passwords do you want to generate? ");

int numPasswords = scanner.nextInt();

scanner.close();

String uniquePasswords = "";

// TODO: Complete the code to generate and print the list of unique passwords

}

}

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago