JustPaste.it

Amortization is a way to pay off a debt over time with equal payments.
Your assignment is to create both a program and a library to handle this problem.

The first part of the problem is to create an "Amort" Library which has at least 3 functions:

  1. double getPaymentAmount(), which returns the amount of each monthly payment ("rounded" up to the next cent).
  2. double getLoanAmount(), which returns the amount of the entire loan (rounded off to the nearest cent).
  3. int getNumberOfMonths(), which returns the number of monthly payments to be made ("rounded" up to the next integer).

These functions should each take 3 parameters and return a single value.
These functions should not do any I/O!

Given i, the monthly interest rate represented as a decimal (yearly rate  1200),  you can calculate:

  • the monthly payment amount;  if you know the principal and the number of monthly payments ("round" up to next cent),
  • the principal (total amount loaned);  if you know the payment amount and the number of months payments are to be made (round off to nearest cent),
  • the number of months;  if you know the payment amount and the total principal ("round" up to next integer).

The formulae are:

  payment= (1 + imonths * principal * i (1 + imonths - 1
  principal = (1 + i ) months - 1 * payment i * (1 + i ) months
  months = logpayment ) - logpayment - (principal * i ))     log( 1 + i )

These functions need to be compiled into your new "Amort.lib"
Don't forget to create an accompanying "Amort.h" file!
Don't forget that ALL functions must have a separate header block!

You will then write a program that helps a users calculate loan payments. You will present a menu of at least three options:

  1. calculate (P)ayment size
  2. calculate (L)oan size
  3. calculate (N)umber of payments
  4. (Q)uit

The user should be able to select an option using either the number or the upper or lower case letter.

  • If the user selects (1), (P) or (p), prompt for and input:
    • the annual interest rate >= 0, round to the nearest 1/8th point)
    • the size of the loan> 0, round to the nearest cent)
    • the number of payments > 0).
  • If the user selects (2), (L) or (l), prompt for and input:
    • the annual interest rate >= 0, round to the nearest 1/8th point)
    • the size of each payment  > (0, round to the nearest cent)
    • the number of payments  > (0).
  • If the user selects (3), (N) or (N), prompt for and input:
    • the annual interest rate  >(= 0, round to the nearest 1/8th point)
    • the size of the loan  > (0, round to the nearest cent)
    • the size of each payment  > (0, round to the nearest cent). 
      Do not allow the user to enter a payment size that is less than or equal to an interest-only payment.
  • If the user selects (4), (Q) or (q), the program should exit 

    The program should continually re-prompt and allow the user to re-enter any non-numeric or out-of-range values. It should not allow the user to enter Interest values of less than zero. If zero is entered for interest, the function called should be able to properly deal with it (i.e., don't allow division by zero).
    In none of the other cases should you allow the user to enter values of zero or less.

For all of these inputs, echo back to the user the number the program will actually use (e.g. if the user enters 88.854 for payment, the program should print back: Monthly Payment :$88.85). The program should then display the results in a friendly manner (money values should be printed to two decimal places, percentage to three decimal places, and the number of months should be a whole number).

 Finally, unless the user has selected the quit option, the sequence should start over again from the menu (use a loop).