- Forum
- General C++ Programming
- Calculate monthly payment for a loan

Hello I need help creating a c++ program using functions, that calculates monthly payment for a loan.

Create a c++ program to help a prospective borrower calculate the monthly payment for a loan. The program also prints the amortization (payoff) table to show the balance of the loan after each monthly payment.

The program prompts the user for input, as shown in the following example:

Amount of the loan (Principal)? 10000.00

Interest rate per year (percent 12)? 10

Number of year? 5

Banks and financial institutions use different formulas to calculate the monthly payment of a loan

For the purpose of this agreement, we use a simple formula

NM=(NY*12)

IM=(IY/12)/100

P=(1+IM)NM

Q=(P/(P-1))

MP=(PR*IM*Q)

where

NY: Scheduled number of years to amortize the loan

NM: Scheduled number of month for the loan

IY: Interest rate per year (as a percentage)

IM: Interest rate/month (decimal)

PR: Principal (the amount of the loan)

P: The value of (1+IM)NM

Q: The value of P/(P-1)

MP: Monthly payment

main must call three other functions: calculateMontlyPayment, printInformation, and printAmortizationTable. Of course, the first function may also call other functions if necessary.

Because of the approximation used in calculation, the value of the new balance at the end of the last month may become nonzero. To prevent this, the last payment must be adjusted. It may be less or greater than the other months. It must be calculated by adding the principal paid to the interest paid for

that month. The new balance at the end of the last month must be zero.

The following example shows the concept. The program has been run for a loan of $5000.00 at 11% interest rate for a period of 1 year. The input was

Amount of the loan (Principal)? 5000.00

Interest rate per year (percent 12)? 11

Number of year? 1

Output:

The amount of the loan (principal): 5000.00

Interest rate/year (percent): 11.0

Interest rate/month (decimal): 0.009167

Number of years: 1

Number of months: 12

Monthly payment: 441.91

Month Old Balance Monthly Payment Interest Paid Principal Paid New Balance

1 5000.0 441.91 45.8 396.08 4603.92

2 4603.92 441.91 42.20 399.71 4204.21

3 4204.21 441.91 38.5 403.37 3800.84

4 3800.00 441.91 34.84 407.07 3393.77

5 3393.77 441.91 31.11 410.80 2982.97

6 2982.97 441.91 27.34 414.57 2568.40

7 2568.40 441.91 23.54 418.37 2150.03

8 2150.03 441.91 19.71 422.20 1727.83

9 1727.83 441.91 15.84 426.07 1301.76

10 1301.76 441.91 11.93 429.98 871.78

11 871.78 441.91 7.99 433.92 437.86

12 437.86 441.91 4.01 437.86 0

Create a c++ program to help a prospective borrower calculate the monthly payment for a loan. The program also prints the amortization (payoff) table to show the balance of the loan after each monthly payment.

The program prompts the user for input, as shown in the following example:

Amount of the loan (Principal)? 10000.00

Interest rate per year (percent 12)? 10

Number of year? 5

Banks and financial institutions use different formulas to calculate the monthly payment of a loan

For the purpose of this agreement, we use a simple formula

NM=(NY*12)

IM=(IY/12)/100

P=(1+IM)NM

Q=(P/(P-1))

MP=(PR*IM*Q)

where

NY: Scheduled number of years to amortize the loan

NM: Scheduled number of month for the loan

IY: Interest rate per year (as a percentage)

IM: Interest rate/month (decimal)

PR: Principal (the amount of the loan)

P: The value of (1+IM)NM

Q: The value of P/(P-1)

MP: Monthly payment

main must call three other functions: calculateMontlyPayment, printInformation, and printAmortizationTable. Of course, the first function may also call other functions if necessary.

Because of the approximation used in calculation, the value of the new balance at the end of the last month may become nonzero. To prevent this, the last payment must be adjusted. It may be less or greater than the other months. It must be calculated by adding the principal paid to the interest paid for

that month. The new balance at the end of the last month must be zero.

The following example shows the concept. The program has been run for a loan of $5000.00 at 11% interest rate for a period of 1 year. The input was

Amount of the loan (Principal)? 5000.00

Interest rate per year (percent 12)? 11

Number of year? 1

Output:

The amount of the loan (principal): 5000.00

Interest rate/year (percent): 11.0

Interest rate/month (decimal): 0.009167

Number of years: 1

Number of months: 12

Monthly payment: 441.91

Month Old Balance Monthly Payment Interest Paid Principal Paid New Balance

1 5000.0 441.91 45.8 396.08 4603.92

2 4603.92 441.91 42.20 399.71 4204.21

3 4204.21 441.91 38.5 403.37 3800.84

4 3800.00 441.91 34.84 407.07 3393.77

5 3393.77 441.91 31.11 410.80 2982.97

6 2982.97 441.91 27.34 414.57 2568.40

7 2568.40 441.91 23.54 418.37 2150.03

8 2150.03 441.91 19.71 422.20 1727.83

9 1727.83 441.91 15.84 426.07 1301.76

10 1301.76 441.91 11.93 429.98 871.78

11 871.78 441.91 7.99 433.92 437.86

12 437.86 441.91 4.01 437.86 0

I need help creating a c++ program |

What help do you need? What is your C++ question? Do you understand the requirements? Have you produced a program design? An algorithm to produce the required output?

Topic archived. No new replies allowed.