Advertisement
BetinaUKTC

Calculator Values

Mar 3rd, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5. public class main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         System.out.print("From >  ");
  10.         String[] from = scan.nextLine().split(": ");
  11.         System.out.print("To >  ");
  12.         String to = scan.nextLine();
  13.         double val = Integer.parseInt(from[1]);
  14.         if (from[0].equalsIgnoreCase("bgn")
  15.                 && to.equalsIgnoreCase("usd")) {
  16.             val *= 0.5677;
  17.             System.out.printf("%.2f USD", val);
  18.         } else if (from[0].equalsIgnoreCase("usd")
  19.                 && to.equalsIgnoreCase("bgn")) {
  20.             val *= 1.7608;
  21.             System.out.printf("%.2f BGN", val);
  22.         } else if (from[0].equalsIgnoreCase("euro")
  23.                 && to.equalsIgnoreCase("bgn")) {
  24.             val *= 1.9558;
  25.             System.out.printf("%.2f BGN", val);
  26.         } else if (from[0].equalsIgnoreCase("bgn")
  27.                 && to.equalsIgnoreCase("euro")) {
  28.             val *= 0.5113;
  29.             System.out.printf("%.2f EUR", val);
  30.         }else if (from[0].equalsIgnoreCase("euro")
  31.                 && to.equalsIgnoreCase("usd")) {
  32.             val *= 1.1109;
  33.             System.out.printf("%.2f USD", val);
  34.         }else if (from[0].equalsIgnoreCase("usd")
  35.                 && to.equalsIgnoreCase("euro")) {
  36.             val *= 0.8998;
  37.             System.out.printf("%.2f EUR", val);
  38.         }else if (from[0].equalsIgnoreCase("pound")
  39.                 && to.equalsIgnoreCase("bgn")) {
  40.             val *= 2.2455;
  41.             System.out.printf("%.2f BGN", val);
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement