dimanche 24 mars 2019

accurate conversion (currency and it cents with fmod)

If I convert 5 USD to Euro, it should be 4.45 or 4 euro and 45 cent the problem is that I get 5 and 0.55 instead of 0.45 or is there a way to get 45 cent??

int main(){

double usd = 0, euro = 0;
double euroval = 0.89;
cout << "Please add amount to convert it";
cin >> usd;
int conv = usd * euroval;
cout << conv  << "\n";
cout << fmod(usd,euroval);

return 0;}

Aucun commentaire:

Enregistrer un commentaire