Advertisement
mswi12

Currency Converter

Aug 24th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class currencyConverterTwo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         Double amount = Double.parseDouble(scanner.nextLine());
  7.         String inputCurrency = scanner.nextLine();
  8.         String outputCurrency = scanner.nextLine();
  9.  
  10.         if (inputCurrency.equals("BGN")){
  11.             amount = amount * 1;
  12.         } else if (inputCurrency.equals("USD")) {
  13.                 amount = amount * 1.79549;
  14.         } else if (inputCurrency.equals("EUR")) {
  15.             amount = amount * 1.95583;
  16.         } else if (inputCurrency.equals("GBP")) {
  17.             amount = amount * 2.53405;
  18.         }
  19.  
  20.         if (outputCurrency.equals("BGN")){
  21.             amount = amount / 1;
  22.         } else if (outputCurrency.equals("USD")) {
  23.             amount = amount / 1.79549;
  24.         } else if (outputCurrency.equals("EUR")) {
  25.             amount = amount / 1.95583;
  26.         } else if (outputCurrency.equals("GBP")) {
  27.             amount = amount / 2.53405;
  28.         }
  29.  
  30.         System.out.printf("%.2f, %s", amount, outputCurrency);
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement