-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathCurrencyConversion.java
More file actions
37 lines (25 loc) · 1.11 KB
/
CurrencyConversion.java
File metadata and controls
37 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.text.DecimalFormat;
public class CurrencyConversion {
static double USD = 1.00;
static double EURO = 0.94;
static double BRITISH_POUND = 0.82;
static double INDIAN_RUPEE = 68.32;
static double AUSTRALIAN_DOLLAR = 1.35;
static double CANADIAN_DOLLAR = 1.32;
static double SINGAPORE_DOLLAR = 1.43;
static double SWISS_FRANC = 1.01;
static double MALAYSIAN_RINGGIT = 4.47;
static double JAPANESE_YEN = 115.84;
static double CHINESE_YUAN_RENMINBI = 6.92;
//NEXT CODEBLOCK INCLUDES:
//Coversion method declaration with parameters
//Coversion formula
//format conversion with DecimalFormat data type
//return it all
public static double converter(double setInitialAmount, double initialCurrency, double targetCurrency)
{
double converted = (setInitialAmount/initialCurrency) * targetCurrency;
DecimalFormat roundDecimalTwoPlaces = new DecimalFormat("#.00");
return Double.parseDouble(roundDecimalTwoPlaces.format(converted));
}
}