I need to create a mortgage calculator program that asks the user to input the loan amount, mortgage term, & interest rate. I am to display the mtge payment amount. I am fine with all of this.
I am then to list the loan balance and interest paid for each pymt over the term of the loan. On longer-term loans, I am not to allow the list to scroll off the screen. I need to display a partial list and then allow the user to continue the list. This is where I am unsure of where to start. I began a for loop, but I don't know if this is in the right direction. I also can't find the formula for calculating the balance. Can anyone point me in the right direction to get started?
using namespace std;
float LOAN_AMOUNT=0; //loan amt
float INT_RATE=0; //interest rate
int TERM_YEARS=0; //loan term in years
char quit; //determines if user wants to quit
//output message asking for loan amt
cout<<"Input the total loan amount:\n";
//output message asking for interest rate
cout<<"Input the annual interest rate:\n";
//output message asking for term in years of loan
cout<<"Input the length of the loan in years:\n";
float RATE=INT_RATE/100; //rate in decimal format
float monthlyInterest; //monthly interest rate
int numberOfPayments; //total number of payments
float payment; //monthly payment
float balance; // loan balance
monthlyInterest=RATE/12; //monthly interest is rate/12
numberOfPayments=TERM_YEARS*12; //# of pymts is length of loan*12
pow(monthlyInterest + 1, numberOfPayments)
* monthlyInterest)/(pow(monthlyInterest + 1,
numberOfPayments) - 1); //pow returns x raised to the power of y
cout<<fixed<<setprecision(2)//cout writes text to the screen
cout<<"Your monthly payment for "
<<TERM_YEARS <<" years\n";
cout<<"for an Interest Rate of "
cout<<"on a Loan Amount of $"
<<" a month\n";
cout<<"Payment Number\tLoan Balance\tInterest Paid\n";
for (int paymentNumber=1; paymentNumber< ? ; ++paymentNumber)
//user can continue in a loop or quit
cout<<"Enter C to continue, Q to quit >";
while((quit!='q') && (quit!='Q') &&
(quit !='c') && (quit !='C'));
while((quit!='q') && (quit!='Q'));
cout<<"Thanks for visiting\n";