This has been bothering me, the teacher told me to make a cash register type program that you enter the total price of stuff and how much the person paid and it tells you how many 20s 10s 5s 1s quarters dimes nickels and pennies to give as change. I thought oh thats f#cking easy so I started to make it. I see no reason why my code doesnt work and like me and 2 other kids are the only ones who he assigned it to because were the only ones way ahead. They cant figure out why it wont work either. I dont have the source code here right now but it as something like this:
float change;
float cash_they_gave;
float TotalPrice;
int twentys, tens, fives, ones, quarters, dimes, nickels;
change = cash_they_gave - TotalPrice;
while(change>=20)
{
change -= 20;
twentys++;
}
while(change>=10)
{
change -= 10;
tens++;
}
etc...
it compiles and but doesnt give me the right numbers.
please help and not turn my post pink.