I've been taking an accelerated C++ program for 3 weeks now...my current assignment is to write a program that, with user input of a mortgage loan amount, the term of the loan, and the interest rate, display the monthly payment. Then list the loan balance and interest paid for each payment over the term of the loan without letting the list scroll off the screen. Allow user to continue viewing list, enter new data, or quit. My program is a mess (don't laugh, the monthly payment portion of the program worked last week). No compile errors, but the calculations are way wrong and the list doesn't stop scrolling. Any help would be greatly appreciated. :-)

Attached is the source file; I'm using Dev- as the compiler.

No compile errors, but the calculations are way wrong

How should the calculations work? what's the formula for calculating it?

and the list doesn't stop scrolling.

There is no break within the for loop, you do have a while loop after it, but it doesn't seem(with your formatting and lack thereof) it is ever going to be used within your printing..

Have you learned about functions yet? You should probably make the while loop into a function and call it to check for screen breaks.

The calculations should show the loan balance and interest paid after each monthly payment. The formulas are:

LoanBalance=Initial Loan Amount - MonthlyPrincipalPaid
Then, the loop should have the same loan balance formula, followed by:
MonthlyInterestPaid=LoanBalance * InterestRate

I'm not sure if these formulas are right.

I'm just beginning to learn about functions, so I will have to do some reading in order to set up the while loop as a function.

How should the calculations work? what's the formula for calculating it?


There is no break within the for loop, you do have a while loop after it, but it doesn't seem(with your formatting and lack thereof) it is ever going to be used within your printing..

Have you learned about functions yet? You should probably make the while loop into a function and call it to check for screen breaks.

Well, after getting a lot of help, I have a working program. I also have a much better understanding of loops now. The source code file is attached.

The calculations should show the loan balance and interest paid after each monthly payment. The formulas are:

LoanBalance=Initial Loan Amount - MonthlyPrincipalPaid
Then, the loop should have the same loan balance formula, followed by:
MonthlyInterestPaid=LoanBalance * InterestRate

I'm not sure if these formulas are right.

I'm just beginning to learn about functions, so I will have to do some reading in order to set up the while loop as a function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.