Due Friday, 1999/10/29
Choose one of the following programming projects. Read the problem carefully and implement it exactly as described, to the best of your ability. Test it on one or more input files of your choosing. Turn in a print-out of the working program, a print-out of the input file, and a print-out of the output of your program (or, you can send all three to me in an e-mail).
The dialogue from your program should look something like this:
$ ./fraction_calc 1/3 + 1/4 1/3 + 1/4 = 7/12 2/3 - 1/6 2/3 - 1/6 = 1/2 2/3 * 3/4 2/3 * 3/4 = 1/2 3/6 / 1/2 3/6 / 1/2 = 1/1 ^D $
Use functions to break the problem down into appropriate sub-problems.
Your goal is to write a program which reads 5 numbers between 1 and 49, and 1 number between 1 and 42 and then "plays" that set of numbers 35 times by using rand() to randomly generate draws. Your program should report any winnings (e.g., "You won the Grand Prize", or "You won $100,000", or "Sorry, try again").
The dialogue from your program should look something like this:
$ ./power_ball Enter 5 numbers between 1 and 49. 4 9 26 12 11 Enter 1 number between 1 and 42. 35 Play 4 9 11 12 26 PB 35 Game 1 Draw 3 6 14 29 30 PB 4 : Sorry, try again. Game 2 Draw 5 6 18 19 39 PB 24 : Sorry, try again. Game 3 Draw 17 19 23 27 29 PB 17 : Sorry, try again. . . .
Use functions to break the problem down into appropriate sub-problems. Note that a user may not "pick" the same number twice, and that as each of the 5 white balls is picked from the drum, it is not replaced until the next round. Your program should sort the 5 white numbers as it prints them.
Copyright © 1999, Ray Ontko (rayo@ontko.com).