Project 4 – Keno

Due: Tuesday, July 27th, 2004

 

 

            To finish out the casino theme this term, the last project you will do is to implement the game of Keno.  Keno is a game much like the lottery.  A player picks seven unique numbers between 1 and 80.  The computer should then pick 20 unique numbers randomly (also in the 1 to 80 range.), display them, and then check to see how many numbers you have matched.

 

Before playing, the user makes a wager. For each $1 they play, the payout is:

 

Number of hits

Winnings per $1

7

$12,000

6

$200

5

$20

4

$1

<4

$0

 

What you need to do

 

Write a program that allows the user to play keno. As usual, have them first enter their name, and then see if they want to play or quit.  If they chose play, ask them how much they want to wager.  A player should start with $100 and be able to bet until they have no more money. After they place their bet, ask for 7 numbers between 1 and 80, making sure that they are unique.  Generate 20 unique numbers for the “board,” display them, and then count how many matches the player has.  Pay out their winnings as per the table above, and add that to their running total.

 

Make sure that you use arrays to hold the user’s numbers and the “board” numbers. Also, you should use methods to help you do the smaller tasks here. You should decide what is appropriate.

 

Example

 

Welcome to Jon’s Casino!

What is your name? Jon

Jon, you have $100, would you like to play or quit? Play

 

How much would you like to bet? 10

 

Please enter 7 unique numbers between 1 and 80.

Enter number 1: 14

Enter number 2: 20

Enter number 3: 81

Sorry, that number is outside of the range, please enter another number between 1 and 80

Enter number 3: 20

Sorry, you’ve already entered that number. Please chose another.

Enter number 3: 15

.

.

.

The computer picks: . . .

 

You matched 4 numbers, you win $10

 

Jon, you have $100, would you like to play or quit? quit

 

Hints

 

To ensure uniqueness, you’ll either need to search the array of numbers every time, or you should use an array of booleans to keep track of what numbers have already been entered.

 

This is a big program, but it’s only incrementally harder than the previous. However, there are a lot of things to do, so make sure you start early enough to test this adequately.

 

Make sure you use good style, and appropriate commenting.

 

Good luck!