program

This is a discussion on program within the C Programming forums, part of the General Programming Boards category; write a program that simulates playing the 6/49 lottery (almost). a 6/49 ticket has six unique numbers on it between ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    14

    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
    Attached Files Attached Files

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    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.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21