Advertisement
veronikaaa86

Currency Convertor111

Jan 13th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.14 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 amount = Double.parseDouble(scanner.nextLine());
  8.         String currencyInput = scanner.nextLine();
  9.         String currencyOutput = scanner.nextLine();
  10.         double result=0.0;
  11.  
  12.         if (currencyInput.equals("BGN")){
  13.             if (currencyOutput.equals("USD")){
  14.                 result =amount/ 1.79549;
  15.                 System.out.printf("%.2f USD", result);
  16.             }
  17.             else if (currencyOutput.equals("EUR")){
  18.                 result = amount/1.95583;
  19.                 System.out.printf("%.2f EUR", result);
  20.             }
  21.             else if (currencyOutput.equals("GBP")){
  22.                 result = amount/2.53405;
  23.                 System.out.printf("%.2f GBP", result);
  24.             }
  25.             else{
  26.                 result = amount;
  27.                 System.out.printf("%.2f BGN", result);
  28.             }
  29.         }
  30.         else if (currencyInput.equals("USD")){
  31.             if (currencyOutput.equals("BGN")){
  32.                 result =amount * 1.79549;
  33.                 System.out.printf("%.2f BGN", result);
  34.             }
  35.             else if (currencyOutput.equals("EUR")){
  36.                 result = amount/1.95583 * 1.79549;
  37.                 System.out.printf("%.2f EUR", result);
  38.             }
  39.             else if (currencyOutput.equals("GBP")){
  40.                 result = amount/2.53405 * 1.79549;
  41.                 System.out.printf("%.2f GBP", result);
  42.             }
  43.             else{
  44.                 result = amount;
  45.                 System.out.printf("%.2f USD", result);
  46.             }
  47.         }
  48.         else if (currencyInput.equals("EUR")){
  49.             if (currencyOutput.equals("USD")){
  50.                 result =amount/ 1.79549 * 1.95583;
  51.                 System.out.printf("%.2f USD", result);
  52.             }
  53.             else if (currencyOutput.equals("BGN")){
  54.                 result = amount * 1.95583;
  55.                 System.out.printf("%.2f BGN", result);
  56.             }
  57.             else if (currencyOutput.equals("GBP")){
  58.                 result = amount/2.53405 * 1.95583;
  59.                 System.out.printf("%.2f GBP", result);
  60.             }
  61.             else{
  62.                 result = amount;
  63.                 System.out.printf("%.2f EUR", result);
  64.             }
  65.         }
  66.         else if (currencyInput.equals("GBP")){
  67.             if (currencyOutput.equals("USD")){
  68.                 result =amount/ 1.79549 * 2.53405;
  69.                 System.out.printf("%.2f USD", result);
  70.             }
  71.             else if (currencyOutput.equals("EUR")){
  72.                 result = amount/1.95583 * 2.53405;
  73.                 System.out.printf("%.2f EUR", result);
  74.             }
  75.             else if (currencyOutput.equals("BGN")){
  76.                 result = amount * 2.53405;
  77.                 System.out.printf("%.2f BGN", result);
  78.             }
  79.             else{
  80.                 result = amount;
  81.                 System.out.printf("%.2f GBP", result);
  82.             }
  83.         }
  84.         else{
  85.             System.out.println("Invalid currency");
  86.         }
  87.  
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement