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 }
2 ответов
+ 3
In this line:
pennies = achange % 1;
You want to divide instead of using modulus.
pennies = achange / 1;
0
I figured it out