posted 13 years ago
Hi, im trying to calculate the amount of each coin given in change and to have the least amount of coins returned. I have a formula going, however, it is only calculating the amount of each coin seperatly. Say there was 9.50 in change, it is returning me change = 9 dollars, 38 quarters, 95 dimes, 190 nickels, 950 pennies. While the answer i was looking for would be 9 dollars, 2 quarters, 0 dimes, 0 nickels, 0 pennies.
It looks as if every time a method runs, the change does not transfer over. Im stuck on how to fix this
The code i have in the main driver is
and the methods from the Machine class