-
Notifications
You must be signed in to change notification settings - Fork 0
/
money_converter.java
29 lines (27 loc) · 1.09 KB
/
money_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
import java.util.Scanner;
public class money_converter {
public static void main(String[]args)
{
Scanner sc= new Scanner(System.in);
System.out.println("Welcome to money converter ");
System.out.println("What do you what to do?");
System.out.println("1.Rupees to Dollars");
System.out.println("2.Dollar to Rupees");
int choice=sc.nextInt();
switch (choice) {
case 1 -> {
System.out.println("Enter the amount:");
float rupees = sc.nextFloat();
float dollar = rupees * 0.012F;
System.out.println(rupees + " rupees is equal to " + String.format("%.2f", dollar) + "dollars");
}
case 2 -> {
System.out.println("Enter the amount:");
float dollar2 = sc.nextFloat();
float rupees2 = dollar2 * 82.44F;
System.out.println(dollar2 + " dollars is equal to " + String.format("%.2f", rupees2) + "rupees");
}
default -> System.out.println("Wrong input !!");
}
}
}