0

I am trying to break the amount entered in pennies into dollars , quarters, dimes, nickels and pennies

if (pay < owed1) cout<< "Insufficent funds " << endl; else { achange = pay - owed1; quarters = achange / 25; // calculate the number of quarters achange = achange % 25; // calculate remaining change needed dimes = achange / 10; // calculate the number of dimes achange = achange % 10; // calculate remaining change needed nickels = achange / 5; // calculate the number of nickels pennies = achange % 1; // calculate pennies }

2nd Oct 2018, 11:14 PM
Timew2
Timew2 - avatar
2 Answers
+ 3
In this line: pennies = achange % 1; You want to divide instead of using modulus. pennies = achange / 1;
3rd Oct 2018, 12:19 AM
Jerid Derply
Jerid Derply - avatar
0
I figured it out
3rd Oct 2018, 1:39 AM
Timew2
Timew2 - avatar