-
program
write a program that simulates playing the 6/49 lottery (almost). a 6/49 ticket has six unique
numbers on it between 1 and 49 (inclusive) a ticket cost $1 for each draw. simulate this for
10 years (520 draws)
the program will buy one ticket for each draw(the ticket should have the same numbers in each draw),
for each draw it will generate the winning ticket and compare the numbers
in your ticket against the winning ticket. you win if u match
match winnings
3 numbers out of 6 $10
4 numbers out of 6 $100
5 numbers out of 6 $2000
6 numbers out of 6 $2000000
for each draw, print the week number, the ticket you have bought and the winning ticket,
do the comparison and print "you lost this week" if you lost. if you won, print the winning
in the form "you won %d this week". where %d is replaced by the winnings, at the end of the program
print your total expenses and total winnings.
two functions to use
generateticket() generate a ticket when passed a six element array of ints.
printticket() prints a ticket when passed a six element array of ints
your main should have a line in it that states
srand ((unsigned) time (NULL));
after your variable declaration. this will randomize the result
sample output of the program
week 517
i bought ticket: ticket: 34 35 19 16 41 9
generating winner: ticket: 11 12 28 39 33 32
you lost this week
week 518
i bought ticket: ticket: 34 35 19 16 41 9
generating winner: ticket: 7 20 27 24 5 10
you lost this week
week 519
i bought ticket: ticket: 34 35 19 16 41 9
generating winner: ticket: 42 39 32 23 15 40
you lost this week
week 520
i bought ticket: ticket: 34 35 19 16 41 9
generating winner: ticket: 6 15 12 20 47 16
you lost this week
total expenses are 520
total winnings are 300
the code is in the attachment, tell me if it is what the program is asking
-
Homework policy:
The purpose of these board is not for other people to do your homework for you. Try things out work on your own, homework has a purpose. If you still have trouble with a specific piece of code or concept please feel free to ask. But please do not ask people to do your entire homework for you, it simply annoys people most of the time.
To OP, compile the code, try it, debug it. If you get stuck with specifics, then open a new thread.