Assignment #5
Due: Thurs, June 26
Objective
This assignment will involve practice with characters and strings, using the libraries
discussed in class (String, StringBuilder, Character)
Task
Write the following exercises, each in a separate file. Filenames should
be:
- Password.java
- PigLatin.java
Exercise 1
Filename: Password.java
Many computer systems, web sites, etc. allow user accounts with
passwords. When allowing users to choose passwords, many systems have
requirements regarding the strength of the chosen password.
Write a program that allows a user to choose a password. The
password is to be a single string of characters that contains no white
space.
- Your program needs to require that the chosen password meets the
following criteria:
- The password must be at least 6 characters long
- The password must contain at least one lowercase letter
- The password must contain at least one uppercase letter
- The password must contain at least one digit
- Whenever the user enters a password that fails to meet one or more
of these criteria:
- Display a an error message informing the user of each criteria
they have not met. (Note: There could be multiple ones).
- Make them re-enter a new password
- Once the user enters a VALID password, ask them to enter it once
more to verify their choice.
- If this entry matches the original chosen password, print a message
saying that their password is now set
- If this entry does not match the chosen password, make them
start the process over from the beginning
Sample Run
(user input is underlined, to distinguish it from output)
Enter your password: mommy1
Password needs to contain at least one uppercase letter
Enter your password: Mom2
Password needs to have 6 or more characters
Enter your password: dad
Password needs to have 6 or more characters
Password needs to contain at least one uppercase letter
Password needs to contain at least one digit
Enter your password: MYNAME4
Password needs to contain at least one lowercase letter
Enter your password: Friend8
Now re-enter your password for verification: Friend
Password does not match. Start over
Enter your password: ClamChowder66
Now re-enter your password for verification: ClamChowder66
You have now entered a valid password
Exercise 2
Filename: PigLatin.java
Write a method, called toPigLatin, which is
described below:
Sample Runs
(user input is underlined, to distinguish it from output)
Sample Run 1
Input 5 words: Flower yellow bypass apple Igloo
Pig Latin version of the 5 words:
Owerflay ellowyay ypassbay appleway Iglooway
Sample Run 2
Input 5 words: string Hamburger Rhythm queen zippitydoodah
Pig Latin version of the 5 words:
ingstray Amburgerhay Ythmrhay ueenqay ippitydoodahzay
Requirements for both programs
- Your code should be readable and well-documented
- You may use any of the libraries discussed in class for dealing with strings and
characters. Suggestions (each of these is in java.lang):
- String
- StringBuilder
- Character
Submitting:
Submit the files through the Assignment 5 Blackboard link. Make sure you
attach BOTH files before you click Submit:
Password.java
PigLatin.java