Complete this project in the on Code-HS and submit a link to your project here.
Your program must contain 3 different functions (main counts as one).
Your program must be correctly indented and should have a comment describing each function.
In this challenge, you will create a guessing game where the computer picks a number between 1 and 100 and the user has to guess it.
Heres how your program should work:
- Generate a random number.
- Have the user repeatedly guess the number. After each guess, the computer should tell them if their guess was too high, too low, or correct.
- If the user guesses the correct number, the game ends.
- Give the user a specific number of guesses. If they run out of guesses, tell them the correct answer and end the game. You can determine the number of guesses by playing a few times to determine the right balance of difficulty.
- After each incorrect guess, tell the user how many guesses they have remaining.
- Make sure to let the user know what they should do at the beginning of the program!
- Challenge: Create multiple levels of difficulty and give the user an option to choose their desired level before playing.
Hints
- There are multiple ways to structure this program, but you will need to use some kind of loop and a break statement.
- Use constants, maybe MIN and MAX, to represent the range of numbers the computer can choose.
- You will need to use the Randomizer to generate a number.
- You can organize the text on the console by using empty print statements (console.log()) or printing a dashed line (console.log(“—–“)).
Final Product
A run of the game could look like this:
This program plays a guessing game.
The computer is thinking of a value between 0 and 100.
What is your guess?
50
Your guess was too low.
Guesses Remaining: 7
————————————
What is your guess?
75
Your guess was too high.
Guesses Remaining: 6
————————————
What is your guess?
65
Your guess was too high.
Guesses Remaining: 5
————————————
What is your guess?
60
Your guess was too high.
Guesses Remaining: 4
————————————
What is your guess?
55
Your guess was too low.
Guesses Remaining: 3
————————————
What is your guess?
57
Your guess was too low.
Guesses Remaining: 2
————————————
What is your guess?
58
Correct!
Game has concluded.
Grading Rubric:
MA 1
MA 1CriteriaRatingsPts
Output
5 pts
Full Marks
Program produces the correct output
3 pts
Partial Marks
Program produces output that is not correct. Some mistakes.
2 pts
No Marks
Program does not produce meaningful output
/ 5 pts
Structure
5 pts
Full Marks
Program contains three functions.
3 pts
Partial Marks
Program contains two functions.
2 pts
No Marks
Program contains one function.
/ 5 pts
Format
5 pts
Full Marks
Program uses correct indentation and each function has a comment describing its purpose.
3 pts
Partial Marks
Program is not correctly indented or functions are missing comments.
2 pts
No Marks
Program is not correctly indented and functions are not commented.
/ 5 pts
Total Points: 0

Leave a Reply
You must be logged in to post a comment.