Please answer my question

Discussion in 'C' started by pirsultanabidal, Jul 20, 2011.

  1. pirsultanabidal

    pirsultanabidal New Member

    Joined:
    Oct 19, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    1) The parents of an 8 children family have bought them each a coin box (kumbara), which store
    only coins. The boxes can distinguish and count different types of coins (that are, 1Kr, 5Kr, 10Kr,
    25Kr, 50Kr, and 100Kr). You are supposed to store in a two-dimensional array each child’s box’s
    current state, which is the current number of coins of each type.
    Sample coin boxes matrix
    1Kr 5Kr 10Kr 25Kr 50Kr 100Kr
    0 1 2 3 4 5
    Veli 0 1 3 5 0 0 1
    Ayşe 1 0 1 1 2 3 0
    Hasan 2 3 12 0 1 0 0
    . 3 . . . . . .
    . 4 . . . . . .
    . 5 . . . . . .
    . 6 . . . . . .
    Ali 7 5 2 1 0 0 9
    a) [ 35p | ] Write a function, named insertCoin, which
    • inputs (as parameters)
    o a two-dimensional array (matrix),
    o coin box number (row number of array from 0 up to 7 since there are 8 children)
    o coin value (1, 5, 10, 25, 50, or 100Kr)
    • updates (the two-dimensional array parameter)
    o by incrementing the necessary column of the specified row.
    b) [ 25p | ] Write a function, named countMoney, which returns the total amount of money
    in all coin boxes in Turkish Liras.
    c) [ 40p | ] Write a sample main, which
    • declares a two-dimensional array for 8 children’s coin boxes.
    • inputs in a loop
    o child no and
    o the value of the coin, (s)he inserted to the box
    • until the user enters an invalid child no.
    • displays the total amount of money in the coin boxes.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice