Results 1 to 4 of 4
Thread: Help!
- 05-14-2011, 06:16 AM #1
Member
- Join Date
- May 2011
- Posts
- 47
- Rep Power
- 0
Help!
I coded my project and I made two changes. I took those changes out and set the project back to the original form. It was running correctly before and displaying the different values in the loop. Now it only displays the same value which is the first value. Need help. This is frustrating. Thanks.
- 05-14-2011, 06:17 AM #2
Member
- Join Date
- May 2011
- Posts
- 47
- Rep Power
- 0
package mortgage;
/**
*
* @author Lekeisha
**/
public class Mortgage
{
public static void main(String[] args)
{
int amLoanOne = 200000;
double monIntRate = 0.0;
double monPay = 0;
monIntRate = .0575/12;
double totMons = 30*12;
double intsPaid = 0;
double princPaid = 0;
double amLoanNxt = 0;
monPay = amLoanOne*monIntRate/(1-(Math.pow((1+monIntRate), (-totMons))));
//calculates the total payment amount for a year with interest rate of 5.75%
for(int i = 0; i < 31; i++)
{
intsPaid+=i;
princPaid+=i;
amLoanNxt+=i;
intsPaid = amLoanOne*monIntRate;
princPaid = monPay - intsPaid;
amLoanNxt = amLoanOne - princPaid;
System.out.println("Interest for this year is $" + Math.round(intsPaid)+ ".");
//calculates the total payment amount for 30 years with interest rate of 5.75%
System.out.println("Mortgage payment amount is $" + Math.round(monPay)+ ".");
System.out.println("Loan balance amount is $" + Math.round(amLoanNxt)+ ".");
}
}
}
- 05-14-2011, 06:19 AM #3
At first glance, without running the code, I'm noticing something that could easily be the issue.
On these three lines of code:
...you appear to overwrite the values of intsPaid, princPaid, and amLoanNxt with constant values from outside of the loop. My guess is that these three lines should be before the loop.Java Code:intsPaid = amLoanOne*monIntRate; princPaid = monPay - intsPaid; amLoanNxt = amLoanOne - princPaid;
PS: When posting code, please use CODE tags. ([code][/code])
- 05-14-2011, 06:35 AM #4
Member
- Join Date
- May 2011
- Posts
- 47
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks