Part A: Password Program

Write a Windows application that simulates entering a password. The user enters a password and clicks Next. Then, the user types the password again and clicks Continue. The program will display a Message Box that displays either that the passwords match or that they don't match.

Sample output: See image.

I type in Bob in the password field and click Next. See image.

I type in Bob in the second password field and click Continue. See image.

Message displayed if the passwords match: See image.

Message displayed if the passwords are different: See image.

Best practice: First make sure to read through this week's lecture and try it yourself! Then, you'll be in good shape for this exercise.

Pseudocode:

Next Button Event Handler Method
If the first password textbox is not blank
Make visible the second password textbox, the Done button, and the labels
Else
Put "You must enter a password" in the label
End-If
Done Button Event Handler Method
If the first password text box is not empty
If the first password text box equals the second password textbox
Display the message "Passwords are the same"
Else
Display the message "Passwords are different"
End-If
Else
Display the message "You must enter a password"
End-If

Part B: Number Guessing Game

Write a Windows application that randomly generates a number from 0 through 100. Prompt the user to guess the number. Let the user know if the guess is too low, too high, or is the correct number. Give the user another chance to guess the number. The user keeps guessing until he or she gets it correct.

Sample output: See image.

I entered a number and pressed the button. See image.

I pressed the button and the box and message are cleared. See image.

I entered a number and pressed the button. After entering several numbers, I got the following: The following message is displayed when the guess is right.

Pseudocode:

Form constructor method

Randomly pick a target number between 0 and 100

Evaluate Button Click Event Handler Method

If the guess text box is not blank
Pull the guess from the text box
Add 1 to the number of guesses
If the guess is less than the target
Make the Evaluate button invisible
Change the label message to "Too Low!!"
Make the label message visible
Change the background color of the form to LightSeaGreen
Make the Try Again button visible
Else if the guess is greater than the target
Make the Evaluate button invisible
Change the label message to "Too High!!"
Make the label message visible
Change the background color of the form to SlateBlue
Make the Try Again button visible
Else
Display a message indicating the user guessed correctly and display the number of guesses it took.
End-If
End-If

Try Again Button Click Event handler

Clear the guess text box
Make the label message and Try Again buttons invisible
Make the Evaluate button visible
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.