12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- public class CurrencyConverter {
-
- public double convertUserInput(double valueOfCurrencyHave, double valueOfCurrencyWant, int amount){
- double value = (valueOfCurrencyWant / valueOfCurrencyHave) * amount;
- String str = String.format("%.02f", value);
- double value2 = Double.parseDouble(str);
- return value2;
- }
-
- public double exchangeRate(String input){
- double value = 0;
- switch(input){
- case "USD":
- value = 1.00;
- break;
- case "EUR":
- value = 0.94;
- break;
- case "GBP":
- value = 0.82;
- break;
- case "INR":
- value = 68.32;
- break;
- case "AUD":
- value = 1.35;
- break;
- case "CAD":
- value = 1.32;
- break;
- case "SGD":
- value = 1.43;
- break;
- case "CHF":
- value = 1.01;
- break;
- case "MYR":
- value = 4.47;
- break;
- case "JPY":
- value = 115.84;
- break;
- case "CNY":
- value = 6.92;
- break;
- }
- return value;
- }
- }
|