making change using int and mod division
Posted on 2003-10-24
I am writing a program that calculates change returned, but I need to do so with both int and mod division. Here are the problems I am having:
1. Once I do int division, how do I do mod division?
2. I want to use a switch, but the compiler won't let use a double as a value in my case, so what value could I use??
here is my code:
case 10.00: tens=(amtChange/10.00)+.005;
case 1.00: dollars = (amtChange / 1.00)+.005;
amtChange = amtChange - (1.00*dollars);
case .25: quarters = (amtChange / .25)+.005;
amtChange = amtChange - (.25 * quarters);
case .10: dimes = (amtChange / .10)+.005;
amtChange = amtChange - (.10 * dimes);
case .05: nickels = (amtChange / .05)+.005;
amtChange = amtChange - (.05 * nickels);
default: pennies = (amtChange / .01)+.005;