3 Replies - 4347 Views - Last Post: 16 September 2008 - 04:00 AM Rate Topic: -----

#1 tiffer032  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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;

			BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
			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 {
Thread.sleep(1500);
} 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  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • 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;


Was This Post Helpful? 0
  • +
  • -

#3 jobs.steve  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 chili5  Icon User is offline

  • D.I.C Lover

Reputation: 20
  • View blog
  • Posts: 1,144
  • 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. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1