CHALLENGE EXERCISE #1
- Print out a welcome message.
- Take in the user's first name as input.
TASK:
Don't allow the user to move forward unless they input a valid first name.
HINT:
Use a loop to print out an error message and re-take in the user's
first name until they enter a valid first name.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
What is a method?
HINT:
Watch the video below to learn about methods.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
More on methods
HINT:
Watch the video below to learn more about methods.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
How can methods return values.
HINT:
Watch the video below to learn about how methods can return a value.
CHECK UP:
Watch the video below to check that you completed the task.
TASK:
Use a method when checking if the first name is composed of all characters.
HINT:
You will need to define a method called "allAlpha()" that takes in
a String as a parameter and returns true if that string is composed of all characters and false otherwise.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #2
- Take in the user's last name making sure that you are checking that it is composed of all characters.
CHALLENGE EXERCISE #3
- Take in the user's zip code as input as a String.
- Check that the user's input is composed of all numerical values by using a user defined method called "isNumString()". This method should take in a String and return true if it is composed of all numbers and false if it is not.
- Do not let the user move forward unless the zip code is in the correct format. Remember that zip codes are composed of 5 numbers.
CHALLENGE EXERCISE #4
- Take in the user's birth year as a String.
- Check that the user's birth year is composed of all numerical values.
- Do not let the user move forward unless the birth year is in the correct format. Remember that birth years must be reasonable.
TASK:
Read in the user's phone number and verify it is in the correct format "XXX-XXX-XXXX".
HINT:
Use the String method charAt() to verify that the hypens
are in the correct position. Then, use the substring method to check that the other components are
composed of all alphabet characters. Lastly, use the length() method to check the length of the phone number.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #5
- Read in the username. There are no restrictions on the username.
- Read in the user's password.
TASK:
Use a method to check that the password is at least 8 characters
long, contains at least 2 numerical values, 1 uppercase letter, and 1 lowercase letter.
HINT:
You will need to use a loop to iterate through each
letter in the String and use a counting variable to count the number of each type of character
using their ASCII values.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #6
- Ask the user to re-enter their desired password.
- Do not let the user move forward unless they reenter a password that matches.
CHALLENGE EXERCISE #7
- Let the user know they have successfully created an account.
Congratulations, you have completed the Data Validation project!