Advertisement
desislava_topuzakova

Untitled

Apr 25th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CurrencyConventor {
  4. public static void main(String[] args) {
  5. Scanner input = new Scanner(System.in);
  6.  
  7.  
  8. double value1 = Double.parseDouble(input.nextLine());
  9.  
  10. String currency1 = input.nextLine();
  11.  
  12. String currency2 = input.nextLine();
  13. double value2 = 0.00;
  14.  
  15. if(currency1.equals("USD") && currency2.equals("BGN"))
  16. {
  17. value2 = value1 * 1.79549;
  18. System.out.printf("%.2f BGN", value2);
  19. }
  20.  
  21. else if (currency1.equals("EUR") && currency2.equals("BGN")) {
  22. value2 = value1 * 1.95583;
  23. System.out.printf("%.2f BGN", value2);
  24. }
  25.  
  26. else if (currency1.equals("GBP") && currency2.equals("BGN")){
  27. value2 = value1 * 2.53405;
  28. System.out.printf("%.2f BGN", value2);
  29. }
  30. else if (currency1.equals("BGN") && currency2.equals("USD")){
  31. value2 = value1 * 0.629525;
  32. System.out.printf("%.2f USD", value2);
  33. }
  34. else if (currency1.equals("BGN") && currency2.equals("EUR")){
  35. value2 = value1 * 0.5113;
  36. System.out.printf("%.2f EUR", value2);
  37. }
  38. else if (currency1.equals("BGN") && currency2.equals("GBP")){
  39. value2 = value1 * 0.449405195;
  40. System.out.printf("%.2f GBP", value2);
  41. }
  42. else if (currency1.equals("EUR") && currency2.equals("USD")){
  43. value2 = value1 * 1.228848;
  44. System.out.printf("%.2f USD", value2);
  45. }
  46. else if (currency1.equals("EUR") && currency2.equals("GBP")){
  47. value2 = value1 * 0.771659919;
  48. System.out.printf("%.2f GBP", value2);
  49. }
  50. else if (currency1.equals("USD") && currency2.equals("EUR")){
  51. value2 = value1 * (1.79549 / 1.95583 );
  52. System.out.printf("%.2f EUR", value2);
  53. }
  54. else if (currency1.equals("USD") && currency2.equals("GBP")){
  55. value2 = value1 * 0.713879823;
  56. System.out.printf("%.2f EUR", value2);
  57. }
  58. else if (currency1.equals("GBP") && currency2.equals("EUR")){
  59. value2 = value1 * 1.13992617;
  60. System.out.printf("%.2f EUR", value2);
  61. }
  62. else if (currency1.equals("GBP") && currency2.equals("USD")){
  63. value2 = value1 * (2.53405 / 1.79549);
  64. System.out.printf("%.2f EUR", value2);
  65. }
  66. else {
  67. System.out.println("Error");
  68. }
  69. input.close();
  70.  
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement