you have a little problem with this statement in your constructor

** long total_cents=(long)money*100;**

dollars=total_cents/100;

cents=total_cents%100;
Here's another way.

let say I'll pass 7.45 (as double primitive type)

First, I'll get the dollar which is 7

I'll just equate it to int or long primitive type. that way, I'll get rid of .45

ex:

int dollar = (int) 7.45; or

long dollar = (long) 7.45;

that way, variable

**dollar** is equal to 7

next I'll get the modulo of 7.45 in 1. that way, I can get the decimal place of the number

int cent = 7.45 % 1; or

long cent = 7.45 % 1;

that way, the value of

**cent** equal to 45. you just need to format it in some case, in this case the modulo is 4500...02.

then return it

return "$" + dollar + " cent" + cent;

of course there is still another way of doing that.

--- Update ---

long total_cents=(long)money*100; -- casting it to long first (7.10 becomes 7) then multiply it to 100 (becomes 700)

dollars=total_cents/100; -- 700 divided by 100 is 7 (just getting the dollar value).

cents=total_cents%100; -- you are just getting the remainder of the dollar when divided by 100.

you can do this

long total_cents=(long) (money*100); -- as you noticed, I put parenthesis in the multiplication so it means to multiply first before casting to long