UMBC CS 201, Fall 99
 UMBC CMSC 201 Fall '99 CSEE | 201 | 201 F'99 | lectures | news | help

 CMSC 201 Programming Project Three B & F LotteryPick-3 Out: Monday 10/25/99 Due: Before Midnight, Sunday 11/7/99

## The Objective

The objective of this assignment is to incorporate all the aspects of C programming we have discussed thus far this semester. This project will give you experience with arrays, arrays used with functions, random number generation and separate compilation.

## The Background

B&F Lottery Inc., is a ficticious private lottery company that gives one the opportunity to play three different lottery games. These lottery games are "Pick-3", "Pick-4" and "Lotto6".

"Pick-3" is a game in which the player chooses a 3-digit number between 0-0-0 and 9-9-9. The player may choose to wager on all 3 digits, or on certain subsets of the three digits. The Pick-3 wager types are:

 All 3 digits First 2 digits Last 2 digits First and Third digits First digit only Second digit only Last digit only

Your task is to write a program that simulates the purchase of a Pick-3 ticket, simulates the drawing of the winning Pick-3 number and calculates the winnings. The following project parameters must be followed--

### Ticket Information

1. Each ticket purchased is for only 1 drawing.
2. The user chooses one 3-digit number per ticket
3. There MUST be 3 wagers on a ticket
4. Wager types (see above) are entered as integers -- a different integer for each wager type
5. Duplicate wager types on the same ticket are permitted
6. Each wager type on the ticket may have a different wager amount
7. As in project 1, wager amounts are between \$.50 and \$5.00 in \$.50 increments

### Winning amounts

The Pick-3 game features "fixed" payouts. The amount won by the user for each \$.50 wager amount is predetermined according to the following table
 Wager Type Payout per \$.50 All 3 digits \$500 First 2 digits \$50 Last 2 digits \$50 First and Third digits \$50 First digit Only \$5 Second digit Only \$5 Third digit Only \$5
For example, if the user chooses the number 1-2-3 and the winning number is 1-2-4, and wagers \$1.00 on each wager type, then
A wager on All 3 Digits wins nothing
A wager on First 2 Digits wins \$100
A wager on Last 2 Digits wins nothing
A wager on First and Third Digits wins nothing
A wager on First Digit Only wins \$10
A wager on Second Digit Only wins \$10
A wager on Third Digit Only wins nothing

### Calculations

Your program must perform and display the following calculations
1. Cost of each ticket purchased
2. Amount won for each ticket
3. Net amount (winnings - cost) for each ticket
4. Total cost of all tickets purchased to be displayed when the user exits
5. Total winnings of all tickets to be displayed when the user exits
6. Net amount for all tickets purchased to be displayed when the user exists

### Other Program requirements

In addition to the items list above, your program must meet the following requirements:
1. Display a greeting to the user
2. When appropriate, display a list of wager types
3. Validate all user input. Reprompt in a user-friendly way when invalid values are input.
4. Generate and display the winning numbers after each ticket purchase
5. Your program must be broken up into multiple source files. The file proj3.c may only contain main. All other functions are contained in the source file named pick3.c
6. You must provide function prototypes and relevant #defines in the file pick3.h
7. Input the random number generator seed value from the user.
DO NOT use the current time to seed the random number generator!!!

## Hints

• Design before you write code......a good design will lead you to several simple functions that make the coding easier
• Use incremental development technique.

## Sample Output

Although your output need not be identical to the above, all information (including the greeting) must be present.

## Submitting the Program

You must submit all files for your project. Late penalties will be determined by the time and date of the last file submitted.

To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.

submit cs201 Proj3 proj3.c pick3.c pick3.h

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 Proj3

CSEE | 201 | 201 F'99 | lectures | news | help

Friday, 22-Oct-1999 11:46:02 EDT