-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrency converter .java
More file actions
76 lines (71 loc) · 2.88 KB
/
currency converter .java
File metadata and controls
76 lines (71 loc) · 2.88 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
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
import java.util.Scanner;
public class CurrencyConverter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("====== Currency Converter ======");
System.out.println("1. INR to USD");
System.out.println("2. INR to EUR");
System.out.println("3. INR to GBP");
System.out.println("4. INR to JPY");
System.out.println("5. USD to INR");
System.out.println("6. EUR to INR");
System.out.println("7. GBP to INR");
System.out.println("8. JPY to INR");
System.out.print("Enter your choice (1-8): ");
int choice = sc.nextInt();
double amount, result;
switch (choice) {
case 1:
System.out.print("Enter amount in INR: ");
amount = sc.nextDouble();
result = amount * 0.012; // Example rate
System.out.println(amount + " INR = " + result + " USD");
break;
case 2:
System.out.print("Enter amount in INR: ");
amount = sc.nextDouble();
result = amount * 0.011;
System.out.println(amount + " INR = " + result + " EUR");
break;
case 3:
System.out.print("Enter amount in INR: ");
amount = sc.nextDouble();
result = amount * 0.0095;
System.out.println(amount + " INR = " + result + " GBP");
break;
case 4:
System.out.print("Enter amount in INR: ");
amount = sc.nextDouble();
result = amount * 1.70;
System.out.println(amount + " INR = " + result + " JPY");
break;
case 5:
System.out.print("Enter amount in USD: ");
amount = sc.nextDouble();
result = amount * 83.0;
System.out.println(amount + " USD = " + result + " INR");
break;
case 6:
System.out.print("Enter amount in EUR: ");
amount = sc.nextDouble();
result = amount * 90.0;
System.out.println(amount + " EUR = " + result + " INR");
break;
case 7:
System.out.print("Enter amount in GBP: ");
amount = sc.nextDouble();
result = amount * 105.0;
System.out.println(amount + " GBP = " + result + " INR");
break;
case 8:
System.out.print("Enter amount in JPY: ");
amount = sc.nextDouble();
result = amount * 0.59;
System.out.println(amount + " JPY = " + result + " INR");
break;
default:
System.out.println("Invalid choice! Please enter between 1-8.");
}
sc.close();
}
}