Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CurrencyConverter {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double amounth = Double.parseDouble(scanner.nextLine());
  8.         String currencyIn = scanner.nextLine().toUpperCase();
  9.         String currencyOut = scanner.nextLine().toUpperCase();
  10.  
  11.         double usdToBgn = 1.79549;
  12.         double eurToBgn = 1.95583;
  13.         double gbpToBgn = 2.53405;
  14.         double inToBgn = 0;
  15.  
  16.         if (currencyIn.equals("BGN")) {
  17.             inToBgn = amounth;
  18.         }
  19.         if (currencyIn.equals("USD")) {
  20.             inToBgn = amounth * usdToBgn;
  21.         }
  22.         if (currencyIn.equals("EUR")) {
  23.             inToBgn = amounth * eurToBgn;
  24.         }
  25.         if (currencyIn.equals("GBP")) {
  26.             inToBgn = amounth * gbpToBgn;
  27.         }
  28.         if (currencyOut.equals("BGN")) {
  29.             amounth = inToBgn;
  30.         }
  31.         if (currencyOut.equals("USD")) {
  32.             amounth = inToBgn / usdToBgn;
  33.         }
  34.         if (currencyOut.equals("EUR")) {
  35.             amounth = inToBgn / eurToBgn;
  36.         }
  37.         if (currencyOut.equals("GBP")) {
  38.             amounth = inToBgn / gbpToBgn;
  39.         }
  40.         System.out.printf("%.2f %s%n", amounth, currencyOut);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement