Public paste
a
By: fookewe | Date: Nov 10 2006 22:30 | Format: None | Expires: never | Size: 1.87 KB | Hits: 1404

  1. Value-returning functions                                              
  2.  
  3. Problem A): (50 points) If a principal amount P, for which the interest is compounded Q times per year, is placed in a savings account, then the amount of money in the account (the balance) after N years is given by the following formula, where I is the annual interest rate as a floating-point number:
  4.  
  5.                 Balance = P x 1 + I  N x Q
  6.                                        Q 
  7.  
  8.         Write an interactive C++ program that inputs the values for P, I, Q, and N and outputs the balance for each year up through year N. Use a value-returning function to compute the balance. This function must receive the principal P, the annual interest I, the number of times the interest is compounded per year Q, and the number of years N. Your program must keep asking the user to enter data for as long as he/she wants it (run my sample solution for a reference).
  9.  
  10. The input of your program should look like the one below:
  11.  
  12. Please enter the following data:
  13.  
  14. Amount of principal (Ex. 5478.52) :$ 266.50                     (P)
  15. Annual interest rate (Ex. 9.25):% 6.75                          (I)
  16. Number of times interest is compounded per year (Ex. 10): 4     (Q)
  17. Number of years: 5                                              (N)
  18. Thank you
  19.  
  20.         The output of your program for an input as the above should look like the following:
  21.  
  22. The balance after 1 years is: $ 284.95
  23. The balance after 2 years is: $ 304.68
  24. The balance after 3 years is: $ 325.77
  25. The balance after 4 years is: $ 348.32
  26. The balance after 5 years is: $ 372.43
  27.  
  28.         After showing the output, your program should ask the following questions and act accordingly to the answer.
  29.  
  30. Enter 'f' or 'F' to finish, any other letter to continue:__     (the answer must be entered next to the prompt, not below)
  31.  
  32.  
  33.  
  34. Note: do not need to round off the balance, just show it with 2 decimal digits.
  35.            For clearing the screen use the statement shown below;
  36.  
  37.         system(cls);
  38.