help with structures

Assume that type Money, a structured type with two int fields, dollars and cents, has been declared. Also assume the availability of a function named normalize that receives a Money argument and returns a "normalized" Money value (i.e. one that is equivalent to the argument but where the cents values is between 0 and 99).

Now write the definition of a function named addMoney that receives two Money arguments and returns their sum, in normalized form. So if the equivalent of $1.85 and $2.19 is passed the function would return the equivalent of $4.04.


----------------

Money addMoney(Money z)
{
Money m;
Money n;

return z;

}

----
any help will be appreciated!!!
Last edited on
I would start with reading up on functions.
You should have dollar and cents as the type float.

What they are asking for is that you have a function named addMoney(..) that will keep track of dollar and cent.
If you input 4 dollar and 250 cent the total would be 6 dollar and 50 cent.

What they mean of 'return' is that the function will return the calculation.

I don't know of how much help this really is but it's a start atleast ^^
Topic archived. No new replies allowed.