Question #5069

Your question (max 1024 symbols)You are required to write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 3.50% to 8.00%, with an increment of 0.25. If you enter the loan amount 5,000 for five years, it will display a table as follows:
Loan Amount: 5000
Number of Years: 5
Interest Rate Monthly Payment Total Payment
3.5% 146.51 5274.37
3.75% 147.06 5294.32
4.0% 147.61 5314.31
…
7.75% 156.1 5619.8
8.0% 156.68 5640.54

Expert's answer

#include <iostream.h>

#include <conio.h>

#include <math.h>

main(){

float L,ap,mp,tp,C;& //L - loan amount, ap - annual payment, mp - monthly payment, tp - total payment, c - interest rate

int Y,N,i; //Y - loan period in years, N - loan period in months, i - counter

cout<<"Enter the loan amount: ";

cin>>L;

cout<<"Enter the loan period: ";

cin>>Y;

cout<<"InterestRate"<<"& quot;<<"MonthlyPayment"<<"& quot;<<"TotalPayment\r\n";

C = 3.5;

for (i=0;i<=18;i++){

& //the month payment is one-twelfth of an annual payment:

& mp = ( L + ( ( L * C/100 ) * Y ) ) / ( Y * 12 );

& //Let's calculate the total payment:

& tp = mp*12*Y;

& //printing results:

& cout<<C<<"%& quot;<<mp<<"& quot;<<tp<<"\r\n";

& //calculating next interest value:

& C = C+0.25;

& }

getch();

}

#include <conio.h>

#include <math.h>

main(){

float L,ap,mp,tp,C;& //L - loan amount, ap - annual payment, mp - monthly payment, tp - total payment, c - interest rate

int Y,N,i; //Y - loan period in years, N - loan period in months, i - counter

cout<<"Enter the loan amount: ";

cin>>L;

cout<<"Enter the loan period: ";

cin>>Y;

cout<<"InterestRate"<<"& quot;<<"MonthlyPayment"<<"& quot;<<"TotalPayment\r\n";

C = 3.5;

for (i=0;i<=18;i++){

& //the month payment is one-twelfth of an annual payment:

& mp = ( L + ( ( L * C/100 ) * Y ) ) / ( Y * 12 );

& //Let's calculate the total payment:

& tp = mp*12*Y;

& //printing results:

& cout<<C<<"%& quot;<<mp<<"& quot;<<tp<<"\r\n";

& //calculating next interest value:

& C = C+0.25;

& }

getch();

}

## Comments

azmir12.11.11, 14:23do i need to fill up the space for loan period and the loan amount?? and how to print screen the answer if i used microsoft visual c++ 2010

## Leave a comment