BubaLazi

p12_CurrencyConverter

Mar 12th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.String;
  3.  
  4. public class CurrencyConverter {
  5.     public static void main(String[] args) {
  6.         Scanner console = new Scanner(System.in);
  7.  
  8.         double ammount = Double.parseDouble(console.nextLine());
  9.         String inputCurency = console.nextLine().toLowerCase();
  10.         String outputCurrency = console.nextLine().toLowerCase();
  11.  
  12.         double totalAmmount = 0;
  13.         double converted = 0;
  14.  
  15.         if(inputCurency.equals("bgn")){
  16.             totalAmmount = ammount;
  17.         }else if(inputCurency.equals("usd")) {
  18.             totalAmmount = ammount * 1.79549;
  19.         }else if(inputCurency.equals("eur")) {
  20.             totalAmmount = ammount * 1.95583;
  21.         }else if(inputCurency.equals("gbp")) {
  22.             totalAmmount = ammount * 2.53405;
  23.         }
  24.  
  25.         if(outputCurrency.equals("bgn")){
  26.             converted = totalAmmount;
  27.         }else if(outputCurrency.equals("usd")) {
  28.             converted = totalAmmount / 1.79549;
  29.         }else if(outputCurrency.equals("eur")) {
  30.             converted = totalAmmount / 1.95583;
  31.         }else if(outputCurrency.equals("gbp")) {
  32.             converted = totalAmmount / 2.53405;
  33.         }
  34.  
  35.         System.out.printf("%.2f %s", converted, outputCurrency );
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment