I am writing a function to return the number of coins needed to return to user based on the cashing_amount value. The below function works fine unless the last digit is a nine. The problem is that it is rounding down for some reason. For example if the user types 356.69, temp resolves to 0.69, then when it is multiplied by a hundred (expecting 69); the value is 68(?????).
int x = static_cast<int>(cashing_amount);
double temp = cashing_amount-x; //get only decimal value
cout<<"temp: "<<temp<<endl;
int coins = static_cast<int>(temp*100); //make whole number
cout<<"coins: "<<coins<<endl;
qtr=coins/25;
coins%=25;
dm=coins/10;
coins%=10;
nk=coins/5;
pn=coins%5;