this assignment needs to be done in visual basic studios nothing else. You will create a Visual Basic solution that plays a number guessing game with the user. The program will randomly generate a...

this assignment needs to be done in visual basic studios nothing else.
You will create a Visual Basic solution that plays a number guessing game with the user. The program will randomly generate a value between one and ten, and will compare the user’s guess to this value. The program will give the user five attempts to guess the correct number. When the user exits the game, the program will display the percentage of guesses that were correct. This program uses counters and accumulators. Download the data file for detailed instructions. You can also view the executable to have the idea on how the program should look like. Be creative, extra features are welcome.





Chapter 5 – Case 1 Chapter 5 – Case 1 Guess My Number Game Figure 1 Instructions In this case, you will create a Visual Basic solution that plays a number guessing game with the user. The program will randomly generate a value between one and ten, and will compare the user’s guess to this value. The program will give the user five attempts to guess the correct number. When the user exits the game, the program will display the percentage of guesses that were correct. This program uses counters and accumulators. Step 1: Create the Project: Create a Visual Basic Project using the project name “GuessMyNumber”. Step 2 – Design the Form: Design the form as shown in Figure 1. You will need three button controls, one text box, and two label controls. Set the Check My Guess button to be the AcceptButton on the form. Step 3 – Declare required variables: You will need to declare four variables to be used as follows: 1. An integer counter variable for the guess limit. 2. An integer accumulator variable to accumulate the number of correct guesses. 3. An integer accumulator variable to accumulate the total number of guesses. 4. An integer variable to store the randomly generated answer value Because these variables must hold their value throughout the time the program is running, declare them as module-level variables in the Form’s Declarations area. Step 4 – Add code in the Form’s Load event to generate an initial random value: In the Form’s Load event, write code to initialize the random object and to generate a random number between 1 and 10. Store the generated number in the answer variable declared above. Step 5 – Add code in the Check My Guess button’s Click event to validate the user input: Use the TryParse method to validate that the user entered a numeric value for the guess. If the textbox value is not numeric, display a message box explaining the error, then put the focus into the textbox with the error. Use the Exit Sub statement to leave the Click event if there was an error. Your validation code for score textboxes should be in this form: If Not Single.TryParse(guessTextBox.Text, guess) Then MessageBox.Show("You must enter a numeric value here.", "Bad value", _ MessageBoxButtons.OK, MessageBoxIcon.Information) guessTextBox.Focus() Exit Sub End If Step 6 – Add code in the Check My Guess button’s Click event to check the guess and display the results: After the validation code, add code to determine if the guess was correct. Display a message indicating if the guess was correct or not. If correct, add 1 to the counter for correct guesses. Add 1 to the guess limit and to the total guesses counters whether the guess was correct or not. Check the guess limit counter to determine if the user has completed five guesses. If so, display a message telling the user the limit has been exceeded, and that the program has a new number to guess. Generate a new random number, and then reset the guess limit counter. Be sure to clear the guess textbox after each guess and put the cursor there to make it quick and easy for the user to enter another guess. Step 7 – Add code in the Start New Game button’s Click event to start a new game: Add code to reset the guess limit counter. Generate a new random number, and display a message box telling the user that the program has a new number to guess. Clear the guess textbox and put the cursor in it. Be sure to add the code for the Clear button and the Exit button. Step 8: Save and run Save all files, then start the application. Test the program using various input values. See if you can guess the number!
Jan 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here