Untitled


SUBMITTED BY: Guest

DATE: Sept. 11, 2014, 10:35 p.m.

FORMAT: Text only

SIZE: 5.6 kB

HITS: 857

  1. /**
  2. * The CurrencyConversion class converts an amount of money from a specific
  3. * country into the equivalent currency of another country given the current
  4. * exchange rate.
  5. *
  6. *
  7. * �CSA/FLVS 2014
  8. * @author Christian Lockley
  9. * @version 09/07/14
  10. */
  11. public class CurrencyConversionV1a
  12. {
  13. public static void main(String [ ] args)
  14. {
  15. // local variable for dollars spent in Mexico
  16. double remainingUsDollars = 0.0; // local variable for US Dollars remaining
  17. //remaining variables below here
  18. // purpose of program
  19. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  20. System.out.println("This program converts an amount of money");
  21. System.out.println("from a specific country into the equivalent");
  22. System.out.println("currency of another country given the current");
  23. System.out.println("exchange rate.");
  24. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  25. System.out.println();
  26. final double startingUsDollars = 5000.00;
  27. remainingUsDollars = startingUsDollars;
  28. // convertion for Mexican pesos
  29. // code goes below here
  30. // local variable for US Dollars
  31. double pesosSpent = 7210.25; // local variable for Mexican pesos spent
  32. double pesoExchangeRate = 13.09149; // local variable for exchange rate of US Dollars to Pesos
  33. double dollarsSpentInMexico = 0.0;
  34. dollarsSpentInMexico = (pesosSpent / pesoExchangeRate);
  35. remainingUsDollars -= dollarsSpentInMexico;
  36. // convertion for Japanese yen
  37. // code goes below here
  38. double yenSpent = 99939.75;
  39. double yenExchangeRate = 0.009505;
  40. double dollarsSpentInJapan = (yenSpent * yenExchangeRate);
  41. remainingUsDollars -= dollarsSpentInJapan;
  42. // convertion for Euros
  43. // code goes below here
  44. //http://www.exchangerate.com/currency-converter/EUR/USD/1/?XR-200Plus_Converter=convert&calc_short_from_iso=284&calc_short_to_iso=239
  45. double euroSpent = 624.95;
  46. double euroExchangeRate = 1.296660;
  47. double dollarsSpentInEuroLand = 624.95;
  48. dollarsSpentInEuroLand = (euroSpent * euroExchangeRate);
  49. remainingUsDollars -= dollarsSpentInEuroLand;
  50. //print output to the screen
  51. // code goes below here
  52. System.out.println("Us dollars spent in Mexico: " + dollarsSpentInMexico);
  53. System.out.println("Us dollars spent in Japan: " + dollarsSpentInJapan);
  54. System.out.println("Us dollars spent in France: " + dollarsSpentInEuroLand);
  55. // Complete the code below. Replace th 0's for totalItem and fundsRemaining
  56. // with the proper calculations. Casting, integer division and the modulus
  57. // operator needed. Do not worry about extra decimal places for the dollar amounts.
  58. System.out.println("========================================================================");
  59. System.out.println("Remaining Us Dollars:" + " " + remainingUsDollars);
  60. System.out.println("");
  61. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  62. System.out.println("Souvenir Purchases");
  63. System.out.println(" (all values in US Dollars) ");
  64. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  65. //Calculations for Souvenir #1
  66. int costPerItem1 = 4; //cost per item of first souvenir
  67. int budget1 = 50; //budget for first item
  68. int totalItem1 = 0; //how many items can be purchased
  69. double fundsRemaining1 = 0.0; //how much of the budget is left
  70. totalItem1 = budget1 / costPerItem1;
  71. /*
  72. * fundsRemaining1 = budget1;
  73. * fundsRemaining1 -= (costPerItem1 * totalItem1);
  74. */
  75. fundsRemaining1 = budget1 % costPerItem1;
  76. System.out.println("Item 1");
  77. System.out.println(" Cost per item: $" + costPerItem1 );
  78. System.out.println(" Budget: $"+ budget1);
  79. System.out.println(" Total items purchased: " + totalItem1);
  80. System.out.println(" Funds remaining: $" + fundsRemaining1);
  81. System.out.println("");
  82. //Calculations for Souvenir #2
  83. double costPerItem2 = 32.55; //cost per item of second souvenir
  84. int budget2 = 713; //budget for second item
  85. int totalItem2 = 0; //how many items can be purchased
  86. double fundsRemaining2 = 0.0; //how much of the budget is left
  87. double tmp = budget2 / costPerItem2;
  88. totalItem2 = (int)tmp;
  89. fundsRemaining2 = budget2 % costPerItem2;
  90. System.out.println("Item 2");
  91. System.out.println(" Cost per item: $" + costPerItem2 );
  92. System.out.println(" Budget: $"+ budget2);
  93. System.out.println(" Total items purchased: " + totalItem2);
  94. System.out.println(" Funds remaining: $" + fundsRemaining2);
  95. } // end of main method
  96. } // end of class

comments powered by Disqus