Skip to content

Hi/Lo

Overview

Compete against the computer by trying to guess a randomly selected number. The player will be notified if their guess is above, below, or correct.

The following user stories will prompt you to build a program with this functionality.

Setup

In Eclipse, create a new Java Project named HiLo.

In the HiLo project, create a new Java Class, with a main method.

Your program will use Math.random to generate a random number between 1 and 20. (Do not show this number to the user.)

User Stories

User Story #1

The user is asked to choose a number between 1 and 20.

User Story #2

The program will then compare their guess with the randomly-generated number. If they are equal, notify the player they have won.

If their guess is not correct, notify the user whether this value is greater than or less than the randomly selected number.

User Story #3

If the user guessed incorrectly they will be prompted to guess again.

User Story #4

If they were correct they will be asked if they would like to play again. If they choose yes, a new number will be randomly generated and the game will begin again.


Up