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

CMSC 201
Programming Project One

B & F Lottery

Out: Wednesday 9/22/99
Due: Before Midnight,Wednesday 9/29/99

The Objective

The objective of this assignment is to get you started writing programs in C in the UNIX environment. This project will give you practice using loops, and mixing data types.

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 000 and 999. Pick-3 drawings are held Tuesday and Thursday at 11:00 PM. If the number selected by the player matches the number drawn, the player wins $500.00 for each $0.50 wager. Pick-3 tickets may be purchased for $0.50 to $5.00 per drawing in $0.50 increments, and for 1 to 7 drawings.

"Pick-4" is a essentially the same game as Pick-3, except that the player chooses a 4-digit number between 0000 and 9999. Pick-4 drawings are held Monday and Wednesday at 11:00 PM. If the number selected by the player matches the number drawn, the player wins $500.00 for each $0.50 wager. Pick-4 tickets may be purchased for $0.50 to $5.00 per drawing in $0.50 increments, and for 1 to 7 drawings.

"Lotto6" is a game in which the player chooses 6 numbers between 1 and 49. Lotto6 drawings are held Saturday at 11:00 PM. The player wins by matching the 6 numbers he selected with the 6 numbers drawn. The player wins according to the following table:

Number of
Matches
Payout
3 of 6$2
4 of 6$40
5 of 6$1,500
6 of 6$1,000,000
Lotto 6 tickets may be purchased for $1.00 to $5.00 per drawing in $1.00 increments, and may be purchased for 1 to 52 drawings.

The Task

Your task is to write a program that inputs ticket data (game, wager amount per draw and number of drawings), validates the ticket data (dependent on the game) then calculates the total ticket cost.

For this program, the following game numbers MUST be used:

Pick-3 is game number 3 Pick-4 is game number 4 Lotto6 is game number 6 Your program should detect invalid game numbers and provide an appropriate error message to the user. Entering game number 0 terminates your program. Wager amounts are input as cents. $0.50 will be input as 50. $1.00 will be input as 100, etc.

Sample Run

[102] a.out Enter game: 3 Pick-3 wagers may be placed from $0.50 to $5.00 in $0.50 increments Enter wager amount (in cents): 150 Pick-3 wagers may be placed for 1 to 7 consecutive drawings Enter number of drawings (1 to 7): 4 Your total ticket cost is $6.00 Enter game: 4 Pick-4wagers may be placed from $0.50 to $5.00 in $0.50 increments Enter wager amount (in cents): 450 Pick-4wagers may be placed for 1 to 7 consecutive drawings Enter number of drawings (1 to 7): 3 Your total ticket cost is $13.50 Enter game: 6 Lotto wagers may be placed from $1.00 to $5.00 in $1 increments Enter wager amount (in cents): 300 Lotto wagers may be placed for 1 to 52consecutive drawings Enter number of Lotto drawings (1 to 52): 40 Your total ticket cost is $120.00 Enter game: 5 Invalid game, please try again Enter game: 0 Thanks for placing wagers with B&F Lottery Inc. [103]

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

Submitting the Program

Your C source code file for this project MUST be called proj1.c.
To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.

submit cs201 Proj1 proj1.c

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 Proj1


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

Tuesday, 21-Sep-1999 23:14:11 EDT