The reason why you are getting the error on "totalInterestPaid" is cause you have declared it inside the while block, due to which it is not visible to any code outside that block and hence you are getting that error.
Move the declaration of the variable to outside the "while" block and the compiler should not complain any longer.
As far as comparing values from different loans is concerned, you will need to use arrays to store the values of the previous loan amounts, to make it possible for them to be compared later, as of now once you have calculated and displayed the values on line 36 above, you overwrite them with the values of the next loan amount.
stephen84s
Nearly a Posting Virtuoso
1,443 posts since Jul 2007
Reputation Points: 668
Solved Threads: 154