CMSC 201
Programming Project Three

201's Modified KENO

Out: Monday 4/1/02
Due: Before Midnight Sunday 4/14/02

The design document for this project, design3.txt, is due: Before Midnight, Sunday 4/07/02

The Objective

The objective of this assignment is for you to practice good design techniques (top-down design that has appropriate use of functions that minimize coupling and maximize cohesion) and to become familiar with using two-dimensional arrays and structures.

The Background

The State of Maryland has a gambling game called KENO. In this project, you will simulate playing KENO, but with slightly easier rules.

For each game of KENO, 20 numbers are chosen randomly from the range of values 1 to 80 and displayed in a grid on a screen. Four rows and five columns are used to display the 20 values. No duplication of numbers are allowed in these values.

In order to play KENO, the player fills out a slip. On the slip s/he must first decide whether s/he wants to try to match only 1 of the 20 numbers, or 2, or more. The number of matches you are trying to make is called the spot. So if the player wants to bet that he can match 4 of the 20 numbers, it is said that he's playing a 4 spot game. The player can choose to play a 1 spot game up to a 10 spot game.

Next the player must decide how much to wager. He can choose to bet $ 1, $ 2, $ 3, $ 4, $5, $ 10, or $ 20 per game. The chart shown below will show the prize value per dollar wagered.

Next the player must choose the numbers he thinks will come up. Obviously, if the player is playing a 3 spot game, he must enter 3 numbers; a 7 spot game, 7 numbers, etc. You must do error checking on the user's input so that s/he does not give duplicate numbers or numbers that are not in the range of 1 to 80, inclusive. In the real KENO game, if you are playing the 3 (or more) spot game, you can win smaller prizes than those shown in the chart below for matching fewer number than the spot of the game. In our modified version, the player must match all 3 numbers to win a 3 spot game. The payouts are shown in the chart below.

KENO Payout Chart

1 spot game match 1 to win $ 2 per $ 1 bet 2 spot game match 2 to win $ 10 per $ 1 bet 3 spot game match 3 to win $ 25 per $ 1 bet 4 spot game match 4 to win $ 50 per $ 1 bet 5 spot game match 5 to win $ 300 per $ 1 bet 6 spot game match 6 to win $ 1000 per $ 1 bet 7 spot game match 7 to win $ 2500 per $ 1 bet 8 spot game match 8 to win $ 10000 per $ 1 bet 9 spot game match 9 to win $ 25000 per $ 1 bet 10 spot game match 10 to win $ 100000 per $ 1 bet Finally, the player must choose how many consecutive Keno games he wants to play using those numbers. S/he may chose 1, 2, 3, 4, 5, 10 or 20 consecutive games.

The real KENO also gives the user the option of playing a bonus, but our version won't deal with bonuses.

The Task

You are to write a program that simulates the playing of KENO, using the CMSC 201 modifications stated above. These modifications will make the coding of the project easier.

You must use a structure to hold the information found on a slip.
Here is the structure definition you are required to use :

typedef struct slip { int spots; int wager; int picks[10]; int games; } SLIP; You must use a two-dimensional array of 4 rows and 5 columns to hold the numbers that are drawn for a single game. Remember no duplicates are allowed.

Your program must calculate the cost of a slip and ask the user for that much money as well as determine whether the customer is a winner and calculate how much his winnings are.

The user can continue to play as long as s/he wants. After each group of consecutive games the user is given the choice to quit or continue playing. To quit the user must enter -1. To continue the user can enter any other integer.

To make grading easier, you must get the seed for the random number generator from the user rather than getting the seed with a call to time. The random number generator should be seeded only one time at the very beginning of your program (Not within any loop). The user's response to the prompt "Please enter any positive integer to begin playing" is to be used as the seed to the random number generator.

Since we are using the same machine with the same operating system, if you use the same seed as I did in the sample run, 7, then the numbers produced by the random number generator will be identical to the ones I got. Use the modulus technique to modify those values to be within the range of 1 to 80, inclusive. When I get a number which is a duplicate, I don't use it and immediately get another random number to use instead. You must use this method to produce your sets of twenty numbers per game so that your program's output will match mine exactly

You will keep track of the total number of games played, the total winnings, and whether the player has broken even, is ahead by how much, or is in the hole by how much. These totals should be shown to the user just before asking if s/he wants to play again.

You are to use separate compilation for this project. You may have as many .c and .h files as you feel are necessary. Group your functions according to their use into appropriately named files.

My Guarantee

I guarantee that all of the input used by the graders will be integers.

Sample Output

linux1[84] % a.out [Game description and rules go here] Please enter any number to begin playing : 7 How many numbers do you want to play ? Please enter an integer between 1 and 10 : 4 Make your wager in dollars (1 - 5, 10 or 20) : 20 Pick a number (1 - 80) : 67 Pick a number (1 - 80) : 42 Pick a number (1 - 80) : 52 Pick a number (1 - 80) : 27 How many consecutive games do you want to play (1 - 5, 10 or 20) : 5 That will be $ 100.00 Game 1 : 38 20 60 32 46 44 27 18 1 74 36 42 52 7 26 41 19 67 51 17 You won $ 1000.00 on this game Game 2 : 25 4 29 30 45 2 33 18 31 14 55 51 73 7 16 68 65 34 69 58 Sorry, you didn't win this time Game 3 : 21 30 61 59 8 78 26 23 14 2 27 42 56 38 41 9 54 79 68 66 Sorry, you didn't win this time Game 4 : 4 12 6 14 64 68 74 42 27 47 71 52 69 5 77 30 23 67 8 15 You won $ 1000.00 on this game Game 5 : 42 16 68 23 27 18 11 5 4 14 48 41 31 28 53 24 54 19 15 57 Sorry, you didn't win this time The total winnings on the 5 games you've played are $2000.00 You're $ 1900.00 ahead Do you want to play again ? Enter -1 to quit or any other integer to play again : 0 How many numbers do you want to play ? Please enter an integer between 1 and 10 : 0 Please enter an integer between 1 and 10 : 11 Please enter an integer between 1 and 10 : 3 Make your wager in dollars (1 - 5, 10 or 20) : 6 Please enter 1 - 5, 10 or 20 : 12 Please enter 1 - 5, 10 or 20 : 21 Please enter 1 - 5, 10 or 20 : 10 Pick a number (1 - 80) : 81 Sorry, 81 is invalid. Pick a number (1 - 80) : 0 Sorry, 0 is invalid. Pick a number (1 - 80) : 17 Pick a number (1 - 80) : 6 Pick a number (1 - 80) : 17 You've already chosen 17 Please choose another number between 1 and 80 : 1 How many consecutive games do you want to play (1 - 5, 10 or 20) : 18 Please enter 1 - 5, 10 or 20 : 21 Please enter 1 - 5, 10 or 20 : 9 Please enter 1 - 5, 10 or 20 : 3 That will be $ 30.00 Game 1 : 39 50 61 6 79 42 60 65 1 26 17 13 80 75 31 10 66 56 78 34 You won $ 250.00 on this game Game 2 : 60 6 35 11 56 49 20 15 51 32 52 1 74 63 17 8 42 73 68 34 You won $ 250.00 on this game Game 3 : 3 18 51 10 15 77 43 26 34 1 61 44 56 63 22 25 40 7 79 65 Sorry, you didn't win this time The total winnings on the 8 games you've played are $2500.00 You're $ 2370.00 ahead Do you want to play again ? Enter -1 to quit or any other integer to play again : 1 How many numbers do you want to play ? Please enter an integer between 1 and 10 : 2 Make your wager in dollars (1 - 5, 10 or 20) : 5 Pick a number (1 - 80) : 9 Pick a number (1 - 80) : 49 How many consecutive games do you want to play (1 - 5, 10 or 20) : 2 That will be $ 10.00 Game 1 : 46 72 27 18 17 3 19 64 54 60 30 2 22 56 35 68 78 48 13 51 Sorry, you didn't win this time Game 2 : 31 59 76 45 18 34 2 80 19 60 49 35 26 51 5 41 56 64 70 9 You won $ 50.00 on this game The total winnings on the 10 games you've played are $2550.00 You're $ 2410.00 ahead Do you want to play again ? Enter -1 to quit or any other integer to play again : -1 linux1[85] %

Submitting the Program

To submit the file you should use the submit command as you have for previous projects

submit cs201 Proj3 proj3.c (followed by all other files necessary to compile your project)

You can check your submission by using the command:

submitls cs201 Proj3