-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrencyConverter.java
More file actions
44 lines (37 loc) · 1.94 KB
/
Copy pathCurrencyConverter.java
File metadata and controls
44 lines (37 loc) · 1.94 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
37
38
39
40
41
42
43
44
import java.util.*;
import java.text.DecimalFormat;
public class CurrencyConverter {
public static void main(String[] args) {
double amount, dollar, pound, code, euro;
DecimalFormat f = new DecimalFormat("##.##");
amount = Integer.parseInt(args[0]);
String curr = args[1];
// For converting currency input to lowercase
String currency = curr.toLowerCase();
// For amounts Conversion
switch (currency){
case "dollars" :
// For Dollar Conversion
pound = amount * 0.74;
System.out.println(amount + " Dollars = " + f.format(pound) + " Pounds");
euro = amount * 0.88;
System.out.println(amount + " Dollars = " + f.format(euro) + " Euros");
break;
case "pounds":
// For Pound Conversion
dollar = amount * 1.36;
System.out.println(amount + " Pounds = " + f.format(dollar) + " Dollars");
euro = amount * 1.19;
System.out.println(amount + " Pounds = " + f.format(euro) + " Euros");
break;
case "euros":
// For Euro Conversion
dollar = amount * 1.13;
System.out.println(amount + " Euros = " + f.format(dollar) + " Dollars");
pound = amount * 0.84;
System.out.println(amount + " Euros = " + f.format(pound) + " Pounds");
break;
}
System.out.println("Thank you for using the converter.");
}
}