Advertisement
igelov

Untitled

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