Coding Exercise: Random Numbers

Test your understanding of random numbers.

Problem

This exercise uses a random number for a guessing game. Create a console application called Guessing Game that meets the four requirements below.

  1. Display the following: Guess the computer’s number between 1 and 10. You have 3 attempts!.
  2. Have the computer select a random number from 1-10.
  3. Have the ability to guess the computer’s number three times.
  4. Display a message saying if the guess was low, high, or correct.

Sample input & output

The finished output of the program should look like the examples below:

Example 1:

Guess the computer's number between 1 and 10. You have 3 attempts!
Guess number 1: 3
You guessed too low!
Guess number 2: 8
You guessed too high!
Guess number 3: 6
You guessed too high!
You LOSE, the number was 4

Get hands-on with 1400+ tech skills courses.