-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrencyConverter.java
220 lines (199 loc) · 9.78 KB
/
currencyConverter.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import java.util.Scanner;
public class currencyConverter {
private static final double USD_TO_EUR_RATE = 0.85;
private static final double EUR_TO_USD_RATE = 1.18;
private static final double IND_TO_PAK_RATE = 3.32;
private static final double PAK_TO_IND_RATE = 0.30;
private static final double IND_TO_AUD_RATE = 0.018;
private static final double AUD_TO_IND_RATE = 56.34;
private static final double IND_TO_CanadianDOLLAR_RATE = 0.016;
private static final double CanadianDOLLAR_TO_IND_RATE = 61.85;
private static final double IND_TO_EURO_RATE = 0.016;
private static final double EURO_TO_IND_RATE = 92.98;
private static final double IND_TO_BrazilianREAL_RATE = 0.067;
private static final double BrazilianREAL_TO_IND_RATE = 14.90;
private static final double IND_TO_JapaneseYEN_RATE = 1.68;
private static final double JapaneseYEN_TO_IND_RATE = 0.60;
private static final double IND_TO_SaudiRIYAL_RATE = 0.045;
private static final double SaudiRIYAL_TO_IND_RATE = 22.35;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("\nWelcome to the Currency Converter!");
while (true) {
// System.out.println("\nMenu:");
System.out.println("Select one of these and convert.....");
System.out.println("\n1. Convert USD to EUR");
System.out.println("2. Convert EUR to USD");
System.out.println("3. Convert IND rupee to PAK rupee");
System.out.println("4. Convert PAK rupee to IND rupee");
System.out.println("5. Convert IND rupee to AUD");
System.out.println("6. Convert AUD to IND rupee");
System.out.println("7. Convert IND rupee to CanadianDollar");
System.out.println("8. Convert CanadianDollar to IND rupee");
System.out.println("9. Convert IND rupee to EURO");
System.out.println("10. Convert EURO to IND rupee");
System.out.println("11. Convert IND rupee to BrazilianREAL");
System.out.println("12. Convert BrazilianREAL to IND rupee");
System.out.println("13. Convert IND rupee to JapaneseYEN");
System.out.println("14. Convert JapaneseYEN to IND rupee");
System.out.println("15. Convert IND rupee to SaudiRIYAL");
System.out.println("16. Convert SaudiRIYAL to IND rupee");
System.out.println("17. Quit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
switch (choice) {
case 1: convertUSDToEUR(scanner);
break;
case 2: convertEURToUSD(scanner);
break;
case 3: convertINDToPAK(scanner);
break;
case 4: convertPAKtoIND(scanner);
break;
case 5: convertINDtoAUD(scanner);
break;
case 6: convertAUDtoIND(scanner);
break;
case 7: convertINDtoCanadianDollar(scanner);
break;
case 8: convertCanadianDollartoIND(scanner);
break;
case 9: convertINDtoEURO(scanner);
break;
case 10: convertEUROtoIND(scanner);
break;
case 11: convertINDtoBrazilianREAL(scanner);
break;
case 12: convertBrazilianREALtoIND(scanner);
break;
case 13: convertINDtoJapaneseYEN(scanner);
break;
case 14: convertJapaneseYENtoIND(scanner);
break;
case 15: convertINDtoSaudiRIYAL(scanner);
break;
case 16: convertSaudiRIYAltoIND(scanner);
break;
case 17:
System.out.println("Thank you for using the Currency Converter!");
scanner.close();
return;
default:
System.out.println("Invalid choice. Please try again.");
System.out.println();
}
}
}
private static void convertUSDToEUR(Scanner scanner) {
System.out.print("Enter the amount in USD: ");
double usdAmount = scanner.nextDouble();
double eurAmount = usdAmount * USD_TO_EUR_RATE;
System.out.println("Result : " + usdAmount + " USD is equivalent to " + eurAmount + " EUR");
System.out.println();
}
private static void convertEURToUSD(Scanner scanner) {
System.out.print("Enter the amount in EUR: ");
double eurAmount = scanner.nextDouble();
double usdAmount = eurAmount * EUR_TO_USD_RATE;
System.out.println("Result : " + eurAmount + " EUR is equivalent to " + usdAmount + " USD");
System.out.println();
}
private static void convertINDToPAK(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double pakAmount = indAmount * IND_TO_PAK_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + pakAmount + " Rupee");
System.out.println();
}
private static void convertPAKtoIND(Scanner scanner) {
System.out.print("Enter the amount in PAK: ");
double pakAmount = scanner.nextDouble();
double indAmount = pakAmount * PAK_TO_IND_RATE;
System.out.println("Result : " + pakAmount + " PAK rupee is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoAUD(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double audAmount = indAmount * IND_TO_AUD_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + audAmount + " AUD");
System.out.println();
}
private static void convertAUDtoIND(Scanner scanner) {
System.out.print("Enter the amount in AUD: ");
double audAmount = scanner.nextDouble();
double indAmount = audAmount * AUD_TO_IND_RATE;
System.out.println("Result : " + audAmount + " AUD is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoCanadianDollar(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double canDollarAmount = indAmount * IND_TO_CanadianDOLLAR_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + canDollarAmount + " CanadianDollar");
System.out.println();
}
private static void convertCanadianDollartoIND(Scanner scanner) {
System.out.print("Enter the amount in Canadian Dollar: ");
double canDollarAmount = scanner.nextDouble();
double indAmount = canDollarAmount * CanadianDOLLAR_TO_IND_RATE;
System.out.println("Result : " + canDollarAmount + " CanadianDollar is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoEURO(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double euroAmount = indAmount * IND_TO_EURO_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + euroAmount + " EURO");
System.out.println();
}
private static void convertEUROtoIND(Scanner scanner) {
System.out.print("Enter the amount in EURO: ");
double euroAmount = scanner.nextDouble();
double indAmount = euroAmount * EURO_TO_IND_RATE;
System.out.println("Result : " + euroAmount + " EURO is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoBrazilianREAL(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double brazilianAmount = indAmount * IND_TO_BrazilianREAL_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + brazilianAmount + " BrazilianREAL");
System.out.println();
}
private static void convertBrazilianREALtoIND(Scanner scanner) {
System.out.print("Enter the amount in Brazilian REAL: ");
double brazilianAmount = scanner.nextDouble();
double indAmount = brazilianAmount * BrazilianREAL_TO_IND_RATE;
System.out.println("Result : " + brazilianAmount + " BrazilianREAL is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoJapaneseYEN(Scanner scanner) {
System.out.print("Enter the amount in IND rupee: ");
double indAmount = scanner.nextDouble();
double japaneseAmount = indAmount * IND_TO_JapaneseYEN_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + japaneseAmount + " Japanese YEN");
System.out.println();
}
private static void convertJapaneseYENtoIND(Scanner scanner) {
System.out.print("Enter the amount in Japanese YEN: ");
double japaneseAmount = scanner.nextDouble();
double indAmount = japaneseAmount * JapaneseYEN_TO_IND_RATE;
System.out.println("Result : " + japaneseAmount + " Japanese YEN is equivalent to " + indAmount + " Rupee");
System.out.println();
}
private static void convertINDtoSaudiRIYAL(Scanner scanner) {
System.out.print("Enter the amount in IND: ");
double indAmount = scanner.nextDouble();
double saudiAmount = indAmount * IND_TO_SaudiRIYAL_RATE;
System.out.println("Result : " + indAmount + " IND rupee is equivalent to " + saudiAmount + " Saudi RIYAL");
System.out.println();
}
private static void convertSaudiRIYAltoIND(Scanner scanner) {
System.out.print("Enter the amount in Saudi RIYAL: ");
double saudiAmount = scanner.nextDouble();
double indAmount = saudiAmount * SaudiRIYAL_TO_IND_RATE;
System.out.println("Result : " + saudiAmount + " Saudi RIYAL is equivalent to " + indAmount + " Rupee");
System.out.println();
}
}