UMBC CS 201, Fall 99
CMSC 201
Programming Project Three
B & F Lottery Pick3
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 "Pick3", "Pick4" and "Lotto6".
"Pick3" is a game in which the player chooses a 3digit number between
000 and 999. The player may choose to wager on all 3 digits, or
on certain subsets of the three digits. The Pick3 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

The Task
Your task is to write a program that simulates the purchase of a
Pick3 ticket, simulates the drawing of the winning Pick3 number
and calculates the winnings. The following project parameters must
be followed
Ticket Information
 Each ticket purchased is for only 1 drawing.
 The user chooses one 3digit number per ticket
 There MUST be 3 wagers on a ticket
 Wager types (see above) are entered as integers  a different integer for
each wager type
 Duplicate wager types on the same ticket are permitted
 Each wager type on the ticket may have a different wager amount
 As in project 1, wager amounts are between $.50 and $5.00 in
$.50 increments
Winning amounts
The Pick3 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 123 and the winning
number is 124, 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
 Cost of each ticket purchased
 Amount won for each ticket
 Net amount (winnings  cost) for each ticket
 Total cost of all tickets purchased to be displayed when the user exits
 Total winnings of all tickets to be displayed when the user exits
 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:
 Display a greeting to the user
 When appropriate, display a list of wager types
 Validate all user input. Reprompt in a userfriendly way when invalid
values are input.
 Generate and display the winning numbers after each ticket purchase
 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
 You must provide function prototypes and relevant #defines in the
file pick3.h
 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
[102] a.out
Welcome to the B & F Lottery Pick3 game
You will be purchasing pick3 tickets with 3 wagers each
I will choose the winning number and calculate your winnings
Good Luck!!
Wager Type Enter Payout per $0.50
  
All 3 Digits 1 $500
First 2 Digits 2 $50
Second 2 Digits 3 $50
First & Third Digits 4 $50
First Digit Only 5 $5
Second Digit Only 6 $5
Third Digit Only 7 $5
Please enter a seed for the random number generator: 23
Enter 1 to wager, 0 to quit: 1
Please enter a Pick3 digit 1: 3
Please enter a Pick3 digit 2: 9
Please enter a Pick3 digit 3: 0
Please enter a Pick3 wager type: 1
Input Pick3 wager amount (cents): 50
Please enter a Pick3 wager type: 4
Input Pick3 wager amount (cents): 350
Please enter a Pick3 wager type: 7
Input Pick3 wager amount (cents): 50
Drawing pick3 numbers....
Pick3 winning numbers: 390
Ticket Info
Cost: $4.50
Winnings: $855.00
Net: $850.50
Enter 1 to wager, 0 to quit: 1
Please enter a Pick3 digit 1: 6
Please enter a Pick3 digit 2: 4
Please enter a Pick3 digit 3: 3
Please enter a Pick3 wager type: 0
Wager Type Enter Payout per $0.50
  
All 3 Digits 1 $500
First 2 Digits 2 $50
Second 2 Digits 3 $50
Third 2 Digits 4 $50
First Digit Only 5 $5
Second Digit Only 6 $5
Third Digit Only 7 $5
Please enter a Pick3 wager type: 5
Input Pick3 wager amount (cents): 400
Please enter a Pick3 wager type: 3
Input Pick3 wager amount (cents): 200
Please enter a Pick3 wager type: 1
Input Pick3 wager amount (cents): 50
Drawing pick3 numbers....
Pick3 winning numbers: 629
Ticket Info
Cost: $6.50
Winnings: $40.00
Net: $33.50
Enter 1 to wager, 0 to quit: 0
Grand Totals
Nr Tickets: 2
Total Cost: $11.00
Total Won : $895.00
Total Net : $884.00
[103]
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, 22Oct1999 11:46:02 EDT