hey guys. the following code should return a percentage of the current values of the object. I keep getting 0 returned. If this isn't enough code let me know.
Money test = ourAmount.percent ( 10 ) ;
test.output ( ) ;
const Money Money::percent ( int percentFigure )
{
return ( percentFigure / 100 * dollars + percentFigure / 100 * cents ) ;
}
void Money::output( ) const
{
int absDollars = abs(dollars);
int absCents = abs(cents);
if (dollars < 0 || cents < 0)//accounts for dollars == 0 or cents == 0
cout << "$-";
else
cout << '$';
cout << absDollars;
if (absCents >= 10)
cout << '.' << absCents;
else
cout << '.' << '0' << absCents;
}