mercredi 19 octobre 2016

Currency Conversion Issue using if else statements result in 0

when multiplying by doubles smaller than 0 such as yen to dollars conversion it results in 0. I attempted to use cast operators and force the conversion to no avail. What am I doing wrong here?

     else if(pick == 3){
            if(pick2 == 1){
            monz2 = (double)monz * (double)0.00967135;
            }
            if(pick2 == 2){
            monz2 = (double)monz * (double)0.00787155;
            }
            }
            if(pick2 == 4){
            monz2 = (double)monz * (double)0.00881142;
            }

1 = Dollars, 2 = pound, 3 = Yen, 4 = Euro in the pick situation. I was told to use if else statements in order to create the options as well as formatting the solution. monz is user input value monz2 is the output after the conversion.

in the final version of the code all of these calculations result in 0 with or without cast operators.

Aucun commentaire:

Enregistrer un commentaire