Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Why is my program hanging

Avatar of cduggins
cduggins asked on
Java
17 Comments1 Solution320 ViewsLast Modified:
I am new to Java and working in this program and for the life of me I can not understand why my program is handing at the Declare 3 new varibles and not running after that:

import java.text.DecimalFormat;

public class mortgage
{
   public static void main (String[] args)
   {
//Declare Varibles
double interest,payment;
int amount,term;
DecimalFormat decimalPlaces=new DecimalFormat("0.00");

//Set interest, amount and term
//interest=.0575;
//amount=200000;
term=30;
double interest = .0575;
double monthlyPayment = 0;

//Calculations for Mortgage Payment
payment=(amount*((interest/12)/(1-Math.pow((1+(interest/12)),-(term*12)))));

//Print the monthly payment to the screen

System.out.println("Duggins Mortgage Calculator");
System.out.println();
System.out.println("Principal="+amount);
System.out.println("intrest rate="+interest*100);
System.out.println("Years="+term);
System.out.println("Number of payments="+term*12);
System.out.print("Monthly Payment= $");
System.out.println(decimalPlaces.format(payment));


//Declares and builds three new variables
double loanBalance = 0;
double interestPaid = 0;
int lineCount = 20;
loanBalance = loanAmount - monthlyPayment;

//Starts loop statement,and declares formula for loan balance and interest paid
while (loanBalance > 0) {

//Displays the loan balance and interest paid
System.out.println("The loan balance is: $" + loanBalance);
System.out.println("The interest paid on the loan is: $" + interestPaid);

loanBalance = loanBalance - monthlyPayment;
interestPaid = monthlyPayment * interest;

//Pauses screen
if (lineCount > 0) {
lineCount--;
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
}
}
}
//Stops loop statement
if (loanBalance <= 0) {
System.out.println("The loan balance is: $0.00");
      }
}
ASKER CERTIFIED SOLUTION
Avatar of ADSLMark
ADSLMark

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answers