If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Mortgage calculator. Please help due soon

I need my code to display Month but it seems my code is skipping month's and not displaying 1, 2 3. It's going 1 , 3 ,5 and so on. This is the code i have for it

Code:

int month = 1;

and later on the code i have month++ That's my first mistake and i'm not sure how to possibly fix it. My second mistake is my Interest Paid output. This is the code i have for it

Code:

interestPaid = loanBalance*i;

This is on the while loop, but i'm not sure why it's not displaying the correct amount. It should display for month 1 = 500.00 , Month 2 = 498.28 and Month 3 = 496.55 and so on... However my code display's something close to it, but not that. i is my monthly interest rate. My code for it seems to be fine. If i can fix this two things i'll be able to finish the project. This is my entire code, someone please help me finish it and tell me how i can fix it so that my month is displayed in 1, 2, 3, etc.... and not 1, 3, 5, etc... And why my interest is not displaying what my professor has on his output screen (i provided the first three months on top in bold) If i can fix those things i'll have the rest. Here's my entire code

The output for principlePaid and loadBalance doesn't line up with the headings. You'll need some extra tabs. Also as the code is, you won't get each months details on a new line. One months details will just start to be displayed straight after the previous months. cout doesn't automatically start a new line when you start a new statement. Unless you specify a new line, cout just starts to output on the screen where the previous cout left off.

Once I changed these on my system, the output seems OK.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

Re: Mortgage calculator. Please help due soon

Ahh okay. Thanks i used endl; and yea it set it right like i needed it. yes i still need to fix the out put. I did what you did and the months are now aligned that was really helpful. Thank you so much.

How about my interest paid output?? I used... For the second month i should be getting 498.28 but what my program gives is 496.56. I know my equation is right, because on my first month i get the same answer but on the second month i'm off by a few dollars. The formula to get monthly interest paid we were given is (loan amount x monthly interest). That's why i told my program

Re: Mortgage calculator. Please help due soon

How about my interest paid output?? I used... For the second month i should be getting 498.28

So did you debug your program? If the program gives the wrong answer, it's your job to debug the program to see why the answer is not correct.

I know my equation is right, because on my first month i get the same answer but on the second month i'm off by a few dollars. The formula to get monthly interest paid we were given is (loan amount x monthly interest). That's why i told my program...

Again, debug your program. Use the debugger that comes with your compiler to see what the value of those variables are, or at the very least, write output statements to see what values variables are during the processing of the program.

Do you guys have any idea if this is right? because it's not giving me what my professor wants

And for us to tell you what is wrong with your program, we have to debug it. So we have to copy your code, compile it, fire up the debugger, step through your code, see the bad results, and then get back to you with our observations and what to fix. Sorry to say this, but these are things that you should really be doing. If you wrote the code, you must know how to debug the code you wrote.

We are experienced programmers that know how to debug programs quickly. However, us debugging your program for you is cheating -- it is no different than someone giving you the code. Debugging is part and parcel of the learning process of how to write a program. It isn't a voluntary skill, it is a mandatory skill. No one writes perfect programs the first time -- when the program doesn't work or does something contrary to what is believed it should be doing, then it's time to debug the program.

Once you step through the program and you cannot figure out what's wrong, then tell us what the values of variables are, what you expected them to be, and what they really are. But to be honest, by that time, you've more than likely figured out the problem yourself and what to fix.