Results 1 to 1 of 1
Thread: Help with Debt Calculator
- 10-08-2011, 03:25 PM #1
Member
- Join Date
- Oct 2011
- Location
- Toronto
- Posts
- 1
- Rep Power
- 0
Help with Debt Calculator
Hi I'm new to Java. I'm writing a method to calculate years it takes to pay off a debt when user enters debt, interest, and payment. I can't seem to get it to output a different result when the user's payment isn't enough to cover the debt. Any help is appreciated. Please see code below:
int debtCalculator(double debt, double interest, double payment) {
//calculate years to pay off debt
int years=0;
double newDebt;
do {
double interestAdded = debt * (interest/100);
debt = interestAdded + debt;
newDebt=debt;
debt = debt - payment;
years++;
}
while ((debt >= 0) && (newDebt>debt));
// check to see if debt is decreasing
if(newDebt>=debt){
System.out.println("Your debt will never be paid off");
return -1;
}
return years;
}
Similar Threads
-
Help with AWT CALCULATOR
By Megan Dosnueve in forum AWT / SwingReplies: 2Last Post: 04-04-2011, 05:49 PM -
Calculator
By water in forum AWT / SwingReplies: 4Last Post: 09-23-2009, 06:00 AM -
help with calculator
By kalibballer in forum New To JavaReplies: 8Last Post: 04-01-2009, 12:57 PM -
help with income to debt ratio calculator
By Anime101 in forum Java AppletsReplies: 1Last Post: 05-23-2008, 08:31 PM -
help with income to debt ratio calculator
By Anime101 in forum New To JavaReplies: 1Last Post: 05-19-2008, 01:44 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks