Spring 2004 CS0007: Introduction to Computer Programming Assignment 6: Keno |
||||||||||||
|
||||||||||||
Reminder: You are not
allowed to every look at or show your program to anyone else working on
the assignment. |
||||||||||||
|
||||||||||||
Keno is
a popular game in casinos and is pretty easy to play. It is a lot
like lotto. Basically, you get a "ticket" containing the numbers
between 1 and 80. You then pick anywhere between 1 and 15 of
these, then turn it in to the casino. At some point, the "board"
shows 20 randomly drawn numbers, and then you hope for lots of
hits (i.e. matches between your picks and those on the board). |
||||||||||||
|
||||||||||||
In this assignment, you are being asked to write a program that will play keno with the user. To simplify the task, we will say that the user will always enter 7 numbers. Of course, there are no duplicates allowed in either the user's picks or the randomly drawn numbers. The program should begin by asking the user for how much to wager and then get the 7 picks. After this, the 20 randomly chosen values are displayed, and the program tells the user the results. For each dollar wagered, the payoff is as follows:
Suppose the user wagers $50 and has 5 hits. In other words, of the 7 numbers chosen, 5 of them were present in the 20 randomly drawn values. In this case, the user wins $20 for each $1 wagered, meaning a $1000 payoff. |
||||||||||||
|
||||||||||||
Here is a sample run of what your program might look like to the user.
|
||||||||||||
|
||||||||||||
This program can get fairly involved, especially if you don't plan it out first. These requirements are important to keep in mind not only because of your program will be graded, but also so you can finish the project.
This can become overwhelming if you are not careful. If you have not studied the book's examples and ran small programs with arrays, you will probably fail miserably at this program. PLEASE PREPARE YOURSELF!!! My advice is to work a little at a time and set small goals. It is not trivial preventing duplicates in these arrays, so set that goal for yourself one night. Sit down and write a program that will load 7 values into an array and skip repeats or numbers out of range. The same idea can be reused when you load the random picks later, only difference is that you are getting the numbers randomly. At the top of this program I have included a link to code that you may find helpful. You can copy these into your program and just call them. They handle some of the little details that you will be facing in this program. |
||||||||||||
|
||||||||||||
As usual, copy your source (.java) and executable (.class) files into the assignment6 handin directory. Please try to avoid copying other files over. |
||||||||||||
© 2003-2004 University of Pittsburgh |