-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrencyConverter.java
More file actions
40 lines (32 loc) · 1.14 KB
/
CurrencyConverter.java
File metadata and controls
40 lines (32 loc) · 1.14 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
import java.util.Scanner;
public class CurrencyConverter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Currency Converter");
System.out.println("------------------");
double usdToInr = 83.0;
double usdToEur = 0.91;
System.out.println("1. USD to INR");
System.out.println("2. USD to EUR");
System.out.println("3. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
if (choice == 3) {
System.out.println("Exiting the converter.");
return;
}
System.out.print("Enter amount in USD: ");
double amount = scanner.nextDouble();
switch (choice) {
case 1:
System.out.println("Converted Amount: " + (amount * usdToInr) + " INR");
break;
case 2:
System.out.println("Converted Amount: " + (amount * usdToEur) + " EUR");
break;
default:
System.out.println("Invalid option.");
}
scanner.close();
}
}