![]() |
|
#1
|
|||
|
|||
Show interest payments on a declining balanceOk so I made this code to show interest payments on a declining balance and it seems to work correctly the first time. But if you choose to run it again with the same input, the output is different.
Here's the code: CPP / C++ / C Code:
example input is: loan amount = 20,000 rate = .1 (for 10%) first time it gives me about 5% annual interest and second time its about 7%. I can't figure out which variables are messing it up the second time around. thanks in advance. |
|||
|
#2
|
||||
|
||||
Re: Show interest payments on a declining balanceQuote:
Scanning through the code, the first obvious problem is that you initialize the variables total_int and time to 0 when declaring them and then use them with the assumption that they are 0. On the second run of the inner loop they will be modified and the residual value will be used in the computation. As a resolution, make sure you initialize the variables before each run of the computation (in the outer loop). Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Classic recursion game of 8 Queens errors | BKizzle77 | Java Forum | 11 | 11-Aug-2008 01:35 |
| Exiting an infinite loop. | memmudu | C++ Forum | 1 | 31-Dec-2007 07:25 |
| Problem with c++ program do while loop | batalia | C++ Forum | 3 | 04-Feb-2007 11:21 |
| Text-Based Roulette Game | mfm1983 | C++ Forum | 5 | 29-Nov-2006 13:20 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The