Results 1 to 5 of 5
 04272012, 08:10 AM #1Member
 Join Date
 Apr 2012
 Posts
 3
 Rep Power
 0
Homework assignment: NEED HELP Please.
So my computer programming class has this for a project this week:
Loan Payoff Project
You have just purchased a stereo that cost $1,000 on the following credit plan: no down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest, and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1,000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt, which leaves you with a debt of $965.00. The next month, you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50  $14.48) from the amount you owe.
Write a program that tells you how many months it will take you to pay off the loan, as well as the total amount of interest paid over the life of the loan. Inside a loop you will need to calculate the amount of interest and the size of the remaining debt after each month. Use a variable to count the number of loop iterations and hence the number of months until the debt is zero. The last payment may be less than $50 if the debt is small, but do not forget the interest. If you owe $50, your monthly payment of $50 will not pay off your debt, althought it will come close. One month’s interest on $50 is only 75 cents.
I have some of it done, but I'm having problems running the program. If someone could please advice me on what I am doing wrong that would be very much appreciated and very helpful. Thank you.
Java Code:public class LoanPayoffProject { public static void main(String[] args) { double debt = 1000; double payment = 50; double interestRate = 0.015; double interest = 0; double totalInterest = 0; double principal = 0; int monthCounter = 0; while (debt > 0); { interest = (debt * interestRate); principal = ((interest  payment) + debt); totalInterest = (totalInterest + interest); principal = (payment  interest); debt = (debt  payment); monthCounter++; System.out.println(Helper.showCurrency(totalInterest)); System.out.println(monthCounter); System.out.println(Helper.showCurrency(principal)); { if (debt < payment) payment = debt + interest; { principal = payment  interest; debt = debt  principal; { System.out.println(Helper.showCurrency(totalInterest)); System.out.println(monthCounter); System.out.println(Helper.showCurrency(principal)); } } } } } }
 04272012, 08:23 AM #2Senior Member
 Join Date
 Apr 2012
 Posts
 199
 Rep Power
 0
Re: Homework assignment: NEED HELP Please.
What errors are you getting?
I noticed one problem. Remove the semicolon after while (debt > 0).
 04272012, 08:44 AM #3Member
 Join Date
 Apr 2012
 Posts
 3
 Rep Power
 0
Re: Homework assignment: NEED HELP Please.
Thank you, I have actually just figured the problem and fixed it. ^_^
 04272012, 08:46 AM #4Member
 Join Date
 Apr 2012
 Posts
 74
 Rep Power
 0
Re: Homework assignment: NEED HELP Please.
You should post what the problem was, and how you fixed, so others like myself might learn.
 04272012, 07:06 PM #5Member
 Join Date
 Apr 2012
 Posts
 3
 Rep Power
 0
Re: Homework assignment: NEED HELP Please.
So here is the final result I got and it runs totally perfectly. If you compare to the original you can see the changes and bugs I worked out.
Java Code:public class LoanPayoff { public static void main(String[] args) { double debt = 1000; double payment = 50; double interestRate = 0.015; double interest = 0; double totalInterest = 0; double principal = 0; int monthCounter = 0; while (debt > 0) { interest = (debt * interestRate); totalInterest = (totalInterest + interest); if (debt < payment) payment = debt + interest; principal = (payment  interest); debt = (debt  principal); monthCounter++; } System.out.println("Total Interest is: " + Helper.showCurrency(totalInterest)); System.out.println("Months to pay off loan is: " + monthCounter + " months"); } }
Similar Threads

Homework Assignment, Need some help
By xdrazkalnytex in forum New To JavaReplies: 3Last Post: 04282012, 12:56 AM 
Homework Assignment, Need some help
By xdrazkalnytex in forum New To JavaReplies: 17Last Post: 04112012, 05:56 PM 
Need Help with Homework Lab Assignment on Loops and File Input/Output
By Terminus_Est in forum New To JavaReplies: 7Last Post: 02292012, 01:15 PM 
Calculator Program HELP NEEDED FAST! Homework assignment
By SteroidalPsycho in forum New To JavaReplies: 3Last Post: 03052009, 04:02 AM
Bookmarks