Ask the user for the amount of the loan and the interest rate and the length of
ID: 3679813 • Letter: A
Question
Ask the user for the amount of the loan and the interest rate and the length of the loan in years. Output a table that has 5 loan amounts in $10000 increments and 4 interest rates in .25% increments. The output needs to be like the one below. this is coded in c++ .
Enter Loan Amount: 10000
Enter interest rate (%): 7
Enter length of loan (years) : 30
Table of Loans
100000 110000 120000 130000 140000
7.00 665.30 731.83 798.36 864.89 931.42
7.25 682.18 750.39 818.61 886.83 955.05
7.50 ........
7.75
Explanation / Answer
Program :
#include<iomanip.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>
class interest1
{
public:
double amount,length,i,n,p,count,interest;
float installment,r;
public:
void accept()
{
cout<< " Enter loan amount: " ;
cin >> amount ;
cout<< "Enter interest rate (%): ";
cin >> interest ;
cout<< "Enter length of loan (years): ";
cin >> length;
}
void display()
{
cout <<" TABLE OF LOAN PAYMENTS ";
for(count=1;count<=5;count++)
{
cout<<" ";
cout<<amount;
amount=amount+10000;
}
}
void check()
{
for(count=1;count<=length;count++)
{
cout<<" ";
cout<<interest;
n=length*12;
r=interest/1200;
p=amount;
for(i=1;i<=5;i++)
{
installment=(p*r*pow((1+r),n)/(pow((1+r),n)-1));
p+=10000;
cout<<" ";
cout<<installment;
}
interest+=0.25;
}
}
};
void main()
{
clrscr();
class interest1 i;
i.accept();
i.display();
i.check();
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.