Homework # 5
Due: Oct. 15, 2004 (F)
Your assignment is to complete the Powerball lottery program started in class. You can download the partial program from http://www.cs.uni.edu/~fienup/cs036f04/homework/pgm5.c .
Recall that the InitializeBins function fills the arrays with "balls" (integers) as
The DrawWinner function randomly selects 5 white balls from the whiteBin to fill index positions 0 to 4 of the drawingResult array, and then it fills position 5 of the drawingResult by randomly selecting a ball from the redBin. For example, the resulting drawingResult might contain the values:
Note that none of the white balls should be repeated since they are not returned to the bin after each is drawn.
The PrintTicket function displays the lottery ticket to the screen using printf. For example, the above ticket might print as:
White Balls: 21 12 53 5 14 Powerball: 12
For extra credit, write a second program (call it pgm5EC.c) that draws a winning lottery ticket, and then generates random lottery tickets until a matching lottery ticket is drawn. The program should count and report the number of random lottery tickets needed before the matching lottery ticket is drawn. Hint: use a "long int" variable for the counter since it might take a while.
Again, use the Linux system to edit, compile, execute, and debug your programs.
To submit your assignment, click on the link at the bottom of the homework page for the course: http://www.cs.uni.edu/~fienup/cs036f04/homework/index.htm
You will need to