fork download
  1. //Diego Martinez CSC5 Chapter 5, P.294,#5
  2. /*******************************************************************************
  3. * CALCULATE YEARLY MEMBERSHIP FEE INCREASE
  4. * ______________________________________________________________________________
  5. * This program calculates and displays how a country club’s membership fee is
  6. * expected to increase over the next six years.
  7. *
  8. *
  9. * Computation is based on the Formula:
  10. * Initial Fee = 2500
  11. * r = 0.04 (4% increase per year)
  12. * n = number of years
  13. * Fee after n years=2500×(1.04)^n
  14. *______________________________________________________________________________
  15. * INPUT
  16. * Initial membership fee : $2500
  17. * Annual increase rate : 4% (0.04)
  18. * Number of years : 6
  19. *
  20. * OUTPUT
  21. * The year number : (Year 1 through Year 6)
  22. * The membership fee for that year after the 4% increase
  23. *******************************************************************************/
  24. #include <iostream>
  25. #include <iomanip>
  26. using namespace std;
  27.  
  28. int main() {
  29. float fee = 2500.0;
  30. const float increaseRate = 0.04;
  31.  
  32. cout << fixed << setprecision(2);
  33.  
  34. for (int year = 1; year <= 6; year++) {
  35. fee += fee * increaseRate;
  36. cout << "Year " << year << ": $" << fee << endl;
  37. }
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Year 1: $2600.00
Year 2: $2704.00
Year 3: $2812.16
Year 4: $2924.65
Year 5: $3041.63
Year 6: $3163.30