lundi 25 mars 2019

How to output the point numbers only, and cut the integer number before the point?

I am a c++ beginner, I want to write a USD/EUR exchange program, for the output I would like to write "You get how much $/€ and cents, but I don't know how, since I have to output only the number of cents.

double eur{0},usd{0},sum{0},kurs{1.14},x,c,d,y;

cout<<"Do you want change Euro or Dollar?"<<endl<<"a is for Euro in Dollar, b is for Dollar in Euro, put a oder b in: "<<endl;

char input = ' ';
cin>>input;
cout<<"Give the sum you want to exchange: ";
cin>>sum;
   if (input == 'a'){
    usd=sum;
    x=usd*kurs;
    y= x*100%100; (MODULO is not usable, error, why?)

    cout<<"You get "<< x <<" dollar and " << y << "cents."

Aucun commentaire:

Enregistrer un commentaire