forked from kalaskarpranav/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurrency_Converter.java
86 lines (86 loc) · 3.43 KB
/
Currency_Converter.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.util.*;
import java.text.DecimalFormat;
// currency converter in java swing
class CurrencyConverter
{
public static void main(String[] args)
{
double rupee,dollar,pound,code,euro,yen;
DecimalFormat f = new DecimalFormat("##.###");
Scanner sc = new Scanner(System.in);
System.out.println("Enter the currency code\n 1:Rupees\n2:Dollar\n3:Pound\n4:Euro\n5:Yen\n");
code=sc.nextInt();
//For Rupees Conversion
if(code == 1)
{
System.out.println("Enter amount in rupees");
rupee = sc.nextFloat();
dollar = rupee / 66;
System.out.println("Dollar : "+f.format(dollar));
pound = rupee / 98;
System.out.println("Pound : "+f.format(pound));
euro = rupee / 72;
System.out.println("Euro : "+f.format(euro));
yen = rupee / 0.55;
System.out.println("Yen : "+f.format(yen));
}
//For Dollar Conversion
else if (code == 2)
{
System.out.println("Enter amount in dollar");
dollar = sc.nextFloat();
rupee = dollar * 66;
System.out.println("Rupees : "+f.format(rupee));
pound = dollar * 0.67;
System.out.println("Pound : "+f.format(pound));
euro = dollar * 0.92;
System.out.println("Euro : "+f.format(euro));
yen = dollar * 120.90;
System.out.println("Yen : "+f.format(yen));
}
//For Pound Conversion
else if(code == 3)
{
System.out.println("Enter amount in Pound");
pound = sc.nextFloat();
rupee = pound * 98;
System.out.println("Rupees : "+f.format(rupee));
dollar = pound * 1.49;
System.out.println("Dollar : "+f.format(dollar));
euro = pound * 1.36;
System.out.println("Euro : "+f.format(euro));
yen = pound * 179.89;
System.out.println("Yen : "+f.format(yen));
}
//For Euro Conversion
else if(code == 4)
{
System.out.println("Enter amount in Euro");
euro = sc.nextFloat();
rupee = euro * 72;
System.out.println("Rupees : "+f.format(rupee));
dollar = euro * 1.09;
System.out.println("Dollar : "+f.format(dollar));
pound = euro * 0.73;
System.out.println("Pound : "+f.format(pound));
yen = euro * 131.84;
System.out.println("Yen : "+f.format(yen));
}
//For Yen Conversion
else if(code == 5)
{
System.out.println("Enter amount in Yen");
yen = sc.nextFloat();
rupee = yen * 0.55;
System.out.println("Rupees : "+f.format(rupee));
dollar = yen * 0.01;
System.out.println("Dollar : "+f.format(dollar));
pound = yen * 0.01;
System.out.println("Pound : "+f.format(pound));
euro = yen * 0.01;
System.out.println("Euro : "+f.format(euro));
}
else
System.out.println("Invalid Code");
}
}