Mortgage Calculator Help

20 errors have no clue!!

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 2117 Views - Last Post: 21 September 2008 - 10:17 AM Rate Topic: -----

#1 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Mortgage Calculator Help

Posted 20 September 2008 - 05:22 AM

I thought for sure that it would compile right...boy was I wrong. I have 20 errors on this one. I do not even know where to start. If someone can point me in the right direction I will gladly thank you now. I think my problem is within the Get Methods but not sure. Here is my code that I have done:

/* Assignment Week 3: McBride Financial Services Mortgage Payment Calculator
   Programmer:		  C. Peach
   Date:			  September 20, 2008
   Filename:		  MortgageCalculator2.java
   Purpose:			  This project will calculate mortgage payment amounts.
*/

import java.io.*;
import java.text.DecimalFormat;



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

		// declare variables

		double orignialLoan = 200000;
		double newLoan = 200000;
		double interest = .0575;
		int months = 360;
		String str = "";
		double payment;

		// print to display monitor

		System.out.println("\t McBride Mortgage Payment Calculator");
		System.out.println();
		System.out.println("\t $200,000.00 Loan");
		System.out.println();
		System.out.println("\t at 5.75% for 30 year term");


		System.out.println();

		DecimalFormat twoDigits = new DecimalFormat("$##,###.##");// Format how it will be displayed.

		// While Statement.

		while (count <= 360)
		{
			orignialLoan = newLoan;
			double interest = getInterest (Rate); // Interest rate for the month.
			double payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			double loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			double interestPayment = payment - loanPayment;// Amount of monthly interest.

		// Print to display moniter.

			System.out.println("The monthly payment on " + orignialLoan + "at 5.75% rate is " + twoDigits.format(payment));
			System.out.println();
			System.out.println("New Balance " + twoDigits.format(newLoan));
			System.out.println("Loan Payment " + twoDigits.format(loanPayment));
			System.out.println("Interest Payment " + twoDigits.format(interestPayment));
			System.out.println();
			System.out.println();
			System.out.println("Continue (y or n): ");
			str = input.nextLine();
			loop = count - 1;

			{ // End While

} // end of main

			// Get Interest Method

			public static double getInterest(double interest)

			{
				double interest = interest / (12 * 100);
				return interest;

			} //  End of Interest Method

			// Get Payment Method

			public static double getPayment (double Interest, double orignialLoan)

			{
				double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
				return payment;

			} // End of Payment Method

			// Get New Loan Amount

			public static double getNewLoan (double Interest, double payment, double orignialLoan)

			{
				double NewLoan = orginialLoan * (1 + Interest) - payment;
				return NewLoan;

			} // End New Loan Amount

} // end program



Is This A Good Question/Topic? 0
  • +

Replies To: Mortgage Calculator Help

#2 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: Mortgage Calculator Help

Posted 20 September 2008 - 05:46 AM

hmm, you code is a bit all over the place. First thing to sort out
{ // End While

it should be }, yours is the wrong way.

double interest = getInterest (Rate); // Interest rate for the month.
			double payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			double loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			double interestPayment = payment - loanPayment;// Amount of monthly interest.




Some of these are already declared at the top, which means you dont need to put the datatype again, so double payment should just be payment. But make sure you declare all the variables you need at the top. for instance you havnt declared interestPayments at the top.
You never declare Rate and loanPayment. You have to just work your way through all your errors cos there are quite alot. Hope this gets you started
Was This Post Helpful? 1
  • +
  • -

#3 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 12:49 AM

View Postnick2price, on 20 Sep, 2008 - 05:46 AM, said:

hmm, you code is a bit all over the place. First thing to sort out
{ // End While

it should be }, yours is the wrong way.

double interest = getInterest (Rate); // Interest rate for the month.
			double payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			double loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			double interestPayment = payment - loanPayment;// Amount of monthly interest.




Some of these are already declared at the top, which means you dont need to put the datatype again, so double payment should just be payment. But make sure you declare all the variables you need at the top. for instance you havnt declared interestPayments at the top.
You never declare Rate and loanPayment. You have to just work your way through all your errors cos there are quite alot. Hope this gets you started



Thank you for the help and I am getting somewhere. I am down from 20 errors to 6! I keep getting these 6 errors no matter what I change and I do not understand why.

These are the errors:

C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:79: cannot find symbol
symbol : variable rate
location: class MortgageCalculator2
interest = rate / (12 * 100);
^
C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:89: cannot find symbol
symbol : variable rate
location: class MortgageCalculator2
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
^
C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:89: cannot find symbol
symbol : variable rate
location: class MortgageCalculator2
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
^
C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:89: operator + cannot be applied to int,<any>
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
^
C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:89: cannot find symbol
symbol : variable months
location: class MortgageCalculator2
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
^
C:\My Program Files\Assignment Programs Made Java\MortgageCalculator2.java:89: pow(double,double) in java.lang.Math cannot be applied to (<nulltype>,int)
double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
^
6 errors

Tool completed with exit code 1

Here is my updated code...can someone explain these errors to me, I have been using this as an error reference but so many things are confusing right now! http://www.skylit.co...-B.html#badcast

import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;



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

		// declare variables

		double orignialLoan = 200000;
		double newLoan = 200000;
		double interest = .0575;
		int months = 360;
		String str = "";
		double payment;
		double rate = .0575;
		double loanPayment = 0;
		double interestPayment = 0;
		char loop = 'y';

		// print to display monitor

		System.out.println("\t McBride Mortgage Payment Calculator");
		System.out.println();
		System.out.println("\t $200,000.00 Loan");
		System.out.println();
		System.out.println("\t at 5.75% for 30 year term");

				Scanner input = new Scanner(System.in);

		System.out.println();

		DecimalFormat twoDigits = new DecimalFormat("$##,###.##");// Format how it will be displayed.

		// While Statement.

		while (loop == 'y')
		{
			orignialLoan = newLoan;
			interest = getInterest (rate); // Interest rate for the month.
			payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			interestPayment = payment - loanPayment;// Amount of monthly interest.

		// Print to display moniter.

			System.out.println("The monthly payment on " + orignialLoan + "at 5.75% rate is " + twoDigits.format(payment));
			System.out.println();
			System.out.println("New Balance " + twoDigits.format(newLoan));
			System.out.println("Loan Payment " + twoDigits.format(loanPayment));
			System.out.println("Interest Payment " + twoDigits.format(interestPayment));
			System.out.println();
			System.out.println();
			System.out.println("Continue (y or n): ");
			str = input.nextLine();
			loop = str.charAt(0);

			} // End While

} // end of main

			// Get Interest Method

			public static double getInterest(double interest)

			{
				interest = rate / (12 * 100);
				return interest;

			} //  End of Interest Method

			// Get Payment Method

			public static double getPayment (double interest, double orignialLoan)

			{
				double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
				return payment;

			} // End of Payment Method

			// Get New Loan Amount

			public static double getNewLoan (double interest, double payment, double orignialLoan)

			{
				double newLoan = (orignialLoan * (1 + interest) - payment);
				return newLoan;

			} // End New Loan Amount

} // end program


Was This Post Helpful? 0
  • +
  • -

#4 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: Mortgage Calculator Help

Posted 21 September 2008 - 04:34 AM

You can get rid of the first 3 errors by including double rate in the parameterlist of your getInterest-method.


public static double getInterest(double interest)

{
interest = rate / (12 * 100);
return interest;

} // End of Interest Method

should be

public static double getInterest(double rate)

{
return rate / (12 * 100); //Is this calculation correct?

} // End of Interest Method


But then I think you have some miscalculations in your code that you may have to address later.

Anyways, errors 4-6 should disappear if you change:

double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));

to

double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), months));

At least this should get you onward.

This post has been edited by Gloin: 21 September 2008 - 04:36 AM

Was This Post Helpful? 1
  • +
  • -

#5 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 05:09 AM

View PostGloin, on 21 Sep, 2008 - 04:34 AM, said:

You can get rid of the first 3 errors by including double rate in the parameterlist of your getInterest-method.


public static double getInterest(double interest)

{
interest = rate / (12 * 100);
return interest;

} // End of Interest Method

should be

public static double getInterest(double rate)

{
return rate / (12 * 100); //Is this calculation correct?

} // End of Interest Method


But then I think you have some miscalculations in your code that you may have to address later.

Anyways, errors 4-6 should disappear if you change:

double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));

to

double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), months));

At least this should get you onward.



I got that all cleared up now I am trying something else and I can not seem to figure it out to save my life. I am putting a counter in the program the problem is I have continue Y or N. well the program works the way i want but if you hit y it does what it is suppose to do...its when i hit N the program will not exit. Been playing with it for a couple of hours now. Any help will thank in advance!!

import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;




public class MortgageCalculator2
{

		static int months = 360;
		static double rate = .0575;


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

		// declare variables

		double orignialLoan = 200000;
		double newLoan = 200000;
		String str = "";
		double payment;
		double loanPayment = 0;
		double interestPayment = 0;
		int i;

		// print to display monitor

		System.out.println("\t McBride Mortgage Payment Calculator");
		System.out.println();
		System.out.println("\t $200,000.00 Loan");
		System.out.println();
		System.out.println("\t at 5.75% for 30 year term");

				Scanner input = new Scanner(System.in);

		System.out.println();

		DecimalFormat twoDigits = new DecimalFormat("$##,###.##");// Format how it will be displayed.

		// For Statement.


			orignialLoan = newLoan;
		for (i = 1; i <= months; i ++)
		{
			double interest = getInterest (rate); // Interest rate for the month.
			payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			interestPayment = payment - loanPayment;// Amount of monthly interest.


		// Print to display moniter.

			System.out.println("The monthly payment on " + twoDigits.format(orignialLoan) + " at 5.75% rate is " + twoDigits.format(payment));
			System.out.println();
			System.out.println("New Balance " + twoDigits.format(newLoan));
			System.out.println("Loan Payment " + twoDigits.format(loanPayment));
			System.out.println("Interest Payment " + twoDigits.format(interestPayment));


			if (i % 3 == 0){

				System.out.println("Continue (Y or N)");
				str = input.nextLine();

				if(input.equals("N") || input.equals("n"))
			{

				break;


			}
				}

			} // End For

} // end of main

			// Get Interest Method

			public static double getInterest(double rate)

			{
				double interest = rate / (12 * 100);
				return interest;

			} //  End of Interest Method

			// Get Payment Method

			public static double getPayment (double interest, double orignialLoan)

			{
				double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
				return payment;

			} // End of Payment Method

			// Get New Loan Amount

			public static double getNewLoan (double interest, double payment, double orignialLoan)

			{
				double newLoan = orignialLoan * (1 + interest) - payment;
				return newLoan;

			} // End New Loan Amount

} // end program


Was This Post Helpful? 0
  • +
  • -

#6 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: Mortgage Calculator Help

Posted 21 September 2008 - 05:16 AM

Try exchanging

break;

for

System.exit(0);
Was This Post Helpful? 0
  • +
  • -

#7 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 05:20 AM

View PostGloin, on 21 Sep, 2008 - 05:16 AM, said:

Try exchanging

break;

for

System.exit(0);



Thanks for trying i tried exchanging break; for System.exit(0);

and if you press any key it still will not exit program until the complete count is finished.
Was This Post Helpful? 0
  • +
  • -

#8 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: Mortgage Calculator Help

Posted 21 September 2008 - 05:39 AM

It might also have to do with how the input is interpreted.

Scanner input = new Scanner(System.in);

str = input.nextLine();

instead, write

str = input.next();
Was This Post Helpful? 0
  • +
  • -

#9 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 06:11 AM

View PostGloin, on 21 Sep, 2008 - 05:39 AM, said:

It might also have to do with how the input is interpreted.

Scanner input = new Scanner(System.in);

str = input.nextLine();

instead, write

str = input.next();



I am at a total loss now. It was running just fine and even before your last couple of post I have managed to screw the whole thing up grrrrrr. It will still compile just fine but somewhere within the logic I have managed to change something and I do not remember what!! :blink: Now it will not go back through the loop...and if you hit anything say Y or N or any key for that matter it just keeps repeating the same information grrrr it is not even doing the loop now. :crazy: My eyes and my head is going crazy!! Here is my last coding that I now have:
import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;




public class MortgageCalculator2
{

		static int months = 360;
		static double rate = .0575;


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

		// declare variables

		double orignialLoan = 200000;
		double newLoan = 200000;
		String str = "";
		double payment;
		double loanPayment = 0;
		double interestPayment = 0;
		int i;

		// print to display monitor

		System.out.println("\t McBride Mortgage Payment Calculator");
		System.out.println();
		System.out.println("\t $200,000.00 Loan");
		System.out.println();
		System.out.println("\t at 5.75% for 30 year term");

				Scanner input = new Scanner(System.in);

		System.out.println();

		DecimalFormat twoDigits = new DecimalFormat("$##,###.##");// Format how it will be displayed.

		// For Statement.


			orignialLoan = newLoan;
		for (i = 1; i <= months; i ++)
		{
			double interest = getInterest (rate); // Interest rate for the month.
			payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			interestPayment = payment - loanPayment;// Amount of monthly interest.


		// Print to display moniter.

			System.out.println("The monthly payment on " + twoDigits.format(orignialLoan) + " at 5.75% rate is " + twoDigits.format(payment));
			System.out.println();
			System.out.println("New Balance " + twoDigits.format(newLoan));
			System.out.println("Loan Payment " + twoDigits.format(loanPayment));
			System.out.println("Interest Payment " + twoDigits.format(interestPayment));


			if (i % 3 == 0){


				System.out.println("Continue? (Y or N)");
				str = input.next();
				if(input.equals("N") || input.equals("n"))
			{

				break;

}
			}


			} // End For

} // end of main

			// Get Interest Method

			public static double getInterest(double rate)

			{
				double interest = rate / (12 * 100);
				return interest;

			} //  End of Interest Method

			// Get Payment Method

			public static double getPayment (double interest, double orignialLoan)

			{
				double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
				return payment;

			} // End of Payment Method

			// Get New Loan Amount

			public static double getNewLoan (double interest, double payment, double orignialLoan)

			{
				double newLoan = orignialLoan * (1 + interest) - payment;
				return newLoan;

			} // End New Loan Amount

} // end program

Was This Post Helpful? 0
  • +
  • -

#10 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 06:46 AM

It seems to be with your if loop within your for, where your instruction is to ask the question if mod/3 = 0 ask the user if they want to exit. But then for loop still has 360 months to loop through. So what you have seemed to create is an infinite loop up to 360 months. You will be able to see this by keep pressing "n" and after a while (360 months), it will exit. So you need to think of another way to do this.
Was This Post Helpful? 0
  • +
  • -

#11 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: Mortgage Calculator Help

Posted 21 September 2008 - 06:52 AM

And you should still change back to System.exit(0);
Was This Post Helpful? 0
  • +
  • -

#12 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 06:54 AM

View Postnick2price, on 21 Sep, 2008 - 06:46 AM, said:

It seems to be with your if loop within your for, where your instruction is to ask the question if mod/3 = 0 ask the user if they want to exit. But then for loop still has 360 months to loop through. So what you have seemed to create is an infinite loop up to 360 months. You will be able to see this by keep pressing "n" and after a while (360 months), it will exit. So you need to think of another way to do this.


I am still here I will have a look at it.....i may change back to the while loop!! I hate to give up but I have been on this all night and it was due yesterday now my eyes are way passed crossed!! But I am still trying to fix it. Shoot I was so happy to get it working this far and I had everything working but stupid me wanted it to show a few and break then when you hit the Y it would show a few more and so on........
Was This Post Helpful? 0
  • +
  • -

#13 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 07:19 AM

View Postcpeachy1223, on 21 Sep, 2008 - 06:54 AM, said:

View Postnick2price, on 21 Sep, 2008 - 06:46 AM, said:

It seems to be with your if loop within your for, where your instruction is to ask the question if mod/3 = 0 ask the user if they want to exit. But then for loop still has 360 months to loop through. So what you have seemed to create is an infinite loop up to 360 months. You will be able to see this by keep pressing "n" and after a while (360 months), it will exit. So you need to think of another way to do this.


I am still here I will have a look at it.....i may change back to the while loop!! I hate to give up but I have been on this all night and it was due yesterday now my eyes are way passed crossed!! But I am still trying to fix it. Shoot I was so happy to get it working this far and I had everything working but stupid me wanted it to show a few and break then when you hit the Y it would show a few more and so on........



********Update to all that have been trying to help me figure this out********

I have managed to get it to go back through the loop it is now subtracting the payments made again!! :D

Now I am just left with getting my counter working right in that it will
respond the right way to the Continue Y or N question. :blink:
Was This Post Helpful? 0
  • +
  • -

#14 cpeachy1223  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 97
  • Joined: 23-September 07

Re: Mortgage Calculator Help

Posted 21 September 2008 - 09:14 AM

Well all I managed to get it to exit out but it still will not answer the Continue Y or N question right. Can someone take another look I see if they can come up with some else that I am missing....just point me in the right direction is all I am looking for.
/* Assignment Week 3: McBride Financial Services Mortgage Payment Calculator
   Programmer:		  C. Peach
   Date:			  September 20, 2008
   Filename:		  MortgageCalculator2.java
   Purpose:			  This project will calculate mortgage payment amounts.
*/

import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;




public class MortgageCalculator2
{

		static int months = 360;
		static double rate = .0575;


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

		// declare variables

		double orignialLoan = 200000;
		double newLoan = 200000;
		String str = "";
		double payment;
		double loanPayment = 0;
		double interestPayment = 0;
		int i;

		// print to display monitor

		System.out.println("\t McBride Mortgage Payment Calculator");
		System.out.println();
		System.out.println("\t $200,000.00 Loan");
		System.out.println();
		System.out.println("\t at 5.75% for 30 year term");

				Scanner input = new Scanner(System.in);

		System.out.println();

		DecimalFormat twoDigits = new DecimalFormat("$##,###.##");// Format how it will be displayed.

		// For Statement.


		for (i = 1; i <= months; i ++)
		{
			orignialLoan = newLoan;
			double interest = getInterest (rate); // Interest rate for the month.
			payment = getPayment (interest, orignialLoan); // Payment per month.
			newLoan = getNewLoan (interest, payment, orignialLoan); // Balance after payment.
			loanPayment = orignialLoan - newLoan; // Amount of monthly loan.
			interestPayment = payment - loanPayment;// Amount of monthly interest.


		// Print to display moniter.

			System.out.println("The monthly payment on " + twoDigits.format(orignialLoan) + " at 5.75% rate is " + twoDigits.format(payment));
			System.out.println();
			System.out.println("New Balance " + twoDigits.format(newLoan));
			System.out.println("Loan Payment " + twoDigits.format(loanPayment));
			System.out.println("Interest Payment " + twoDigits.format(interestPayment));


			if (i % 3 == 0){


				System.out.println("Continue? (Y or N)");
				str = input.nextLine();
				if(input.equals("N") || input.equals("n"))

				{

				System.exit(0);
			}
					else return;{
					}
			}


		} // End For

} // end of main

			// Get Interest Method

			public static double getInterest(double rate)

			{
				double interest = rate / (12 * 100);
				return interest;

			} //  End of Interest Method

			// Get Payment Method

			public static double getPayment (double interest, double orignialLoan)

			{
				double payment = (orignialLoan * getInterest(rate)) / (1 - Math.pow(1 + getInterest(rate), - months));
				return payment;

			} // End of Payment Method

			// Get New Loan Amount

			public static double getNewLoan (double interest, double payment, double orignialLoan)

			{
				double newLoan = orignialLoan * (1 + interest) - payment;
				return newLoan;

			} // End New Loan Amount

} // end program

Was This Post Helpful? 0
  • +
  • -

#15 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Mortgage Calculator Help

Posted 21 September 2008 - 09:24 AM

It is ths String "str" that you have to compare with "N" or "n" not the Scanner "input"

If the user replies something else than N or n you should just continue not "return"

	if (i % 3 == 0){
		System.out.println("Continue? (Y or N)");
		str = input.nextLine();
		if(str.equals("N") || str.equals("n"))
			System.exit(0);
	}


Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2