This code needs to be written in C#: If the user guesses the number in 3rd try you will assign: Points = (10 – 3)^2/100 = 7 ^ 2 = 49 points. When the user presses the ‘Start Game’ button, the game will start. User will enter a number in the large textbox and press Submit. If number is correct display the Messagebox, else continue with game. Also tell the user if the number entered was higher or lower than actual number. The problem flow will be as follows: 1. Player enters name and number of chances 2. Player presses Start game 3. Computer generates a secret random number 4. Player enters choice 5. Program checks if number matches guesses number. If number matches jump to step #10 6. Program updates message whether the guessed number is more or less than actual 7. Program reduces available chances by 1 and display messages on changes 8. If chances become 0 stop game and tell use Game has ended, and she will have to press ‘Start Game’ again. Same message should be spoken by the program using text to speech. Note that player gets 0 points if she does not win 9. Repeat steps 4-8 10. If user has guessed the number correctly, display a message box that he won the game and total point accumulated by user based on point system above 11. Using Text to Speech, the program also speaks the message that is displayed Make sure your code follows these guidelines (you will lose points if any guideline is not followed):  Display the initial screen with correct layout   The game state should be maintained inside a separate class   The random number generation should be in separate class   The separate class should not have any user interface (MessageBox etc)   Correctly compute the points won by the user   Code should be well commented and indented  Code should compile and run without any error or warnings and should work correctly as per the specifications   Code uses exception handling to handle incorrect input from user   Text to speech works correctly if user wins or loses

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This code needs to be written in C#:

If the user guesses the number in 3rd try you will assign:
Points = (10 – 3)^2/100 = 7 ^ 2 = 49 points.
When the user presses the ‘Start Game’ button, the game will start. User will enter a number in the large
textbox and press Submit. If number is correct display the Messagebox, else continue with game. Also tell
the user if the number entered was higher or lower than actual number.
The problem flow will be as follows:
1. Player enters name and number of chances
2. Player presses Start game
3. Computer generates a secret random number
4. Player enters choice
5. Program checks if number matches guesses number. If number matches jump to step #10
6. Program updates message whether the guessed number is more or less than actual
7. Program reduces available chances by 1 and display messages on changes
8. If chances become 0 stop game and tell use Game has ended, and she will have to press ‘Start Game’
again. Same message should be spoken by the program using text to speech. Note that player gets 0 points
if she does not win
9. Repeat steps 4-8
10. If user has guessed the number correctly, display a message box that he won the game and total point
accumulated by user based on point system above
11. Using Text to Speech, the program also speaks the message that is displayed
Make sure your code follows these guidelines (you will lose points if any guideline is not followed):
 Display the initial screen with correct layout 
 The game state should be maintained inside a separate class 
 The random number generation should be in separate class 
 The separate class should not have any user interface (MessageBox etc) 
 Correctly compute the points won by the user 
 Code should be well commented and indented
 Code should compile and run without any error or warnings and should work correctly as per
the specifications 
 Code uses exception handling to handle incorrect input from user 
 Text to speech works correctly if user wins or loses 

In this assignment, you will create a WinForm-based guessing game. The user will be asked for their name and how many chances they want (up to a maximum of 10). The program will then randomly generate a number between 1 and 30, prompting the user to guess the number within the specified number of tries. If the user guesses correctly, they will be notified and awarded points based on the speed of their guess.

### User Interface Preview

The User Interface (UI) for your program should appear similar to the sample shown:

- **Title**: UHCL Number Guessing Game
- **Fields**:
  - **Your Name**: An input field for the user's name.
  - **Number of tries**: An input field for the number of tries the user desires.
- **Buttons**:
  - **Start Game**: Initiates the guessing game.
- **Game Display**:
  - **Enter your guess**: Displays the guessed number.
  - **Submit**: Button to submit the user's guess.

- **Feedback and remaining chances**:
  - Displays a message indicating if the guessed number is lower or higher than the actual number.
  - Shows the number of remaining chances.

### Scoring System

Use the following formula to calculate the points:

\[ \text{Points} = (10 - \text{NumberOfTries})^2 \]

For example, if the user guesses the number on their first try:

\[ \text{Points} = (10 - 1)^2 = 81 \, \text{points} \]

This simple game helps to enhance logical thinking and problem-solving skills by requiring quick and accurate guesses.
Transcribed Image Text:In this assignment, you will create a WinForm-based guessing game. The user will be asked for their name and how many chances they want (up to a maximum of 10). The program will then randomly generate a number between 1 and 30, prompting the user to guess the number within the specified number of tries. If the user guesses correctly, they will be notified and awarded points based on the speed of their guess. ### User Interface Preview The User Interface (UI) for your program should appear similar to the sample shown: - **Title**: UHCL Number Guessing Game - **Fields**: - **Your Name**: An input field for the user's name. - **Number of tries**: An input field for the number of tries the user desires. - **Buttons**: - **Start Game**: Initiates the guessing game. - **Game Display**: - **Enter your guess**: Displays the guessed number. - **Submit**: Button to submit the user's guess. - **Feedback and remaining chances**: - Displays a message indicating if the guessed number is lower or higher than the actual number. - Shows the number of remaining chances. ### Scoring System Use the following formula to calculate the points: \[ \text{Points} = (10 - \text{NumberOfTries})^2 \] For example, if the user guesses the number on their first try: \[ \text{Points} = (10 - 1)^2 = 81 \, \text{points} \] This simple game helps to enhance logical thinking and problem-solving skills by requiring quick and accurate guesses.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
ListBox
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education