I am new to coding and I am having trouble getting a currency converter project to actually work. I am having a extremely hard time getting this program to work. Because I am new to this I know no advanced techniques. I am only allowed to use integer and double. My professor says the trick is to
- add .005 to the orginal number.
- multiply this value times 100
- typecast result to an int.
- divide this value by 100.0 (wouldn't this make the error lossy conversion from double to int?)
- Final value will be the original number rounded to 2 decimal places.
So for example I have the user inputing dollars as an integer. I then have them subtract a 2.75 conversion fee (part of project) Then we take that number and multiply it by .90 (current-ish rate of dollar per euro). If I enter in $500 I get €447.5250000003. I need it to say 447.53. I have never used this site so I don't know what you all need, please just ask. dollarsDoubled should be 500.0 in this specific case. I have set up a scanner for user input so I need the code to work for any given amount. The conversion fee is 2.75. I have been trying this for hours so I am sorry if you see blatant mistakes
double remainingCash = dollarsDoubled - conversion fee;
remainingCash = remainingCash + .005;
double caash = remainingCash * 100;
int cashCash = (int)caash;
double x = cashCash / 100;
I am using BlueJ so I belive it is in Java