Advertisement
Guest User

CurrencyConverter

a guest
Oct 29th, 2016
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. package SimpleCalculations;
  2.  
  3. import java.io.IOException;
  4. import java.util.Objects;
  5. import java.util.Scanner;
  6.  
  7. public class CurrencyConverter {
  8. public static void main(String[] args) throws IOException {
  9. Scanner console = new Scanner(System.in);
  10. double eur = 1.95583;
  11. double gbp = 2.53405;
  12. double usd = 1.79549;
  13. double a = Double.parseDouble(console.nextLine());
  14. String b = console.nextLine();
  15. String c = console.nextLine();
  16. double val = 0.0;
  17. double val1= 0.0;
  18.  
  19. if (Objects.equals(b, "BGN"))
  20. {
  21. val = a;
  22. }
  23. if (Objects.equals(b, "EUR"))
  24. {
  25. val = a * eur;
  26. }
  27. if (b.equals("USD")) {
  28. val = a * usd;
  29. }
  30. if (Objects.equals(b, "GBP")) {
  31. val = a * gbp;
  32. }
  33. ////System.out.println(val);
  34. ////System.in.read();
  35. if (Objects.equals(c, "BGN")) {
  36. val1 = val; // triabva da ima posledovatelnost, taka se definirat, triabva double или decimal всички да са еднакви
  37. System.out.printf("%.2f %s", val1, c);
  38. }
  39. if (Objects.equals(c, "EUR")) {
  40. val1 = val / eur;
  41. System.out.printf("%.2f %s", val1, c);
  42. }
  43. if (Objects.equals(c, "USD"))
  44. {
  45. val1 = val / usd;
  46. System.out.printf("%.2f %s", val1, c);
  47. }
  48. if (Objects.equals(c, "GBP")) {
  49. val1 = val / gbp;
  50. System.out.printf("%.2f %s", val1, c);
  51. }
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement