Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CurrencyConverter {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double amounth = Double.parseDouble(scanner.nextLine());
- String currencyIn = scanner.nextLine().toUpperCase();
- String currencyOut = scanner.nextLine().toUpperCase();
- double usdToBgn = 1.79549;
- double eurToBgn = 1.95583;
- double gbpToBgn = 2.53405;
- double inToBgn = 0;
- if (currencyIn.equals("BGN")) {
- inToBgn = amounth;
- }
- if (currencyIn.equals("USD")) {
- inToBgn = amounth * usdToBgn;
- }
- if (currencyIn.equals("EUR")) {
- inToBgn = amounth * eurToBgn;
- }
- if (currencyIn.equals("GBP")) {
- inToBgn = amounth * gbpToBgn;
- }
- if (currencyOut.equals("BGN")) {
- amounth = inToBgn;
- }
- if (currencyOut.equals("USD")) {
- amounth = inToBgn / usdToBgn;
- }
- if (currencyOut.equals("EUR")) {
- amounth = inToBgn / eurToBgn;
- }
- if (currencyOut.equals("GBP")) {
- amounth = inToBgn / gbpToBgn;
- }
- System.out.printf("%.2f %s%n", amounth, currencyOut);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement