help with dividing doubles into integers

This is a discussion on help with dividing doubles into integers within the C++ Programming forums, part of the General Programming Boards category; I am trying to compile this program but I keep getting an error message telling me that I'm converting doubles ...

help with dividing doubles into integers

I am trying to compile this program but I keep getting an error message telling me that I'm converting doubles to integers, which I am trying to do, but I can't get it to compile. It's in the "else if " statement near the bottom. It is trying to divide the double "change" into the integers "twenties, tens, etc."
This is not important really but the program is supposed to implement a cash register and if the amount tendered is more the amount of the purchase it will show you how much change you owe, according to the number of twenties, tens, fives, etc.

Also, it's preferred to use getchar() instead of system("pause")
I also see vart react to
tender > amount && change == 0
Which brings up the question: if the customers pays more than the exact amount, how can the change be 0? You got a little logic problem there.

As for the doubles problem... Well, any decimals are floats or doubles. Anything like 0.20 is a double and anything like 0.20f is a float. And when you divide with a double or float, you'll get a float or double as result. And you can't assign a double or float to an int without an explicit cast. So either define all the variables as floats or truncate the result back into an integer via a cast.