Advertisement
Ivakis

Currency Converter

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