# Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

Page 1 of 1

## 3 Replies - 5061 Views - Last Post: 16 September 2008 - 04:00 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=21888&amp;s=58aaab21d0a116dd5ea38df67a3f552f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 tiffer032

Reputation: 0
• Posts: 1
• Joined: 10-December 06

# Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

Posted 10 December 2006 - 11:04 AM

Hello I am having a problem with Mortgage program my teacher gave an example but something is not right with mine. I need to show monthly payment interest payment prinicpleamount
here is my code
```import java.io.*;
import java.text.DecimalFormat;

public class test12056
{

public static void main(String[] args) throws IOException
{

String usrEnter;

int loanAmount = 200000;
int loanTerm = 360;
double interest = .0575;
double monthlyPayment = 0;

DecimalFormat twoDigits = new DecimalFormat("0.00");

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

//Displays the Mortgage calculator
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is \$200,000");
System.out.println("The term of the loan is 30 years");
System.out.println("The interest rate applied to the loan is 5.75%");
System.out.println();

//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 {
} catch (InterruptedException e) {
}
}
}
//Stops loop statement
if (loanBalance <= 0) {
System.out.println("The loan balance is: \$0.00");
}
```

Is This A Good Question/Topic? 0

## Replies To: Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

### #2 horace

• D.I.C Lover

Reputation: 768
• Posts: 3,832
• Joined: 25-October 06

## Re: Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

Posted 10 December 2006 - 12:57 PM

should you not have a value specified for monthlyPayment, e.g.
```   double monthlyPayment = 500;

```

### #3 jobs.steve

Reputation: 0
• Posts: 1
• Joined: 15-September 08

## Re: Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

Posted 15 September 2008 - 08:57 PM

I want learn Java, Java is the computer language to do something different in my career so I selected this course. I want more details about this please send me details.
========================
Jobs.steve

Foreclosed Homes

### #4 chili5

• D.I.C Lover

Reputation: 20
• Posts: 1,146
• Joined: 28-December 07

## Re: Java MortgageCalculation for 200,000 interest rate 5.75 for term 30yea

Posted 16 September 2008 - 04:00 AM

^ Make your own topic please Your problem is monthly payment is set to 0 which is messing you up.