Mortgage Calculator with Graph

Have error and do not seem to get it fixed! Plz..Help

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 13096 Views - Last Post: 04 May 2010 - 08:00 PM Rate Topic: -----

#16 cpeachy1223   User is offline

  • D.I.C Head

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

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 09:15 PM

View Postpbl, on 10 Nov, 2008 - 08:13 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 06:38 PM, said:

Sweet...pbl that did the trick on the compile error. Now I am only getting the compile errors because those variables are not defined! :D


"Sweet...pbl" ... I hope you are a she :D

		   int dblLoanDuration;
		   double xincrement = (width/(dblLoanDuration*12));



Java complains about the fact that db;:oanDuration might not have been initialized
And the Java compiler is right... you were abou to divide by 0


LOL pbl.........yes I am a she ;) and I will check into the oops!
Was This Post Helpful? 0
  • +
  • -

#17 cpeachy1223   User is offline

  • D.I.C Head

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

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 09:26 PM

View Postcpeachy1223, on 10 Nov, 2008 - 08:15 PM, said:

View Postpbl, on 10 Nov, 2008 - 08:13 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 06:38 PM, said:

Sweet...pbl that did the trick on the compile error. Now I am only getting the compile errors because those variables are not defined! :D


"Sweet...pbl" ... I hope you are a she :D

		   int dblLoanDuration;
		   double xincrement = (width/(dblLoanDuration*12));



Java complains about the fact that db;:oanDuration might not have been initialized
And the Java compiler is right... you were abou to divide by 0


LOL pbl.........yes I am a she ;) and I will check into the oops!


OK..I fixed the dblLoanAmount and set it to 200000. Now for the dblLoanDuration how is it best to hard code that in the duration is 3 different numbers 7, 15, 30. Which would be the easiest to go without changing a bunch of things around or can it be done that way?
Was This Post Helpful? 0
  • +
  • -

#18 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 09:47 PM

View Postcpeachy1223, on 10 Nov, 2008 - 08:26 PM, said:

[LOL pbl.........yes I am a she ;) and I will check into the oops!

What oops ?
Happy to know that you are a she :)
OK there must be a play of words here that I can't understand, due to my lack of knowledge of the Shakespeare language ...
Seriously... still due to my understanding of Shakespeare
OK..I fixed the dblLoanAmount and set it to 200000. Now for the dblLoanDuration how is it best to hard code that in the duration is 3 different numbers 7, 15, 30. Which would be the easiest to go without changing a bunch of things around or can it be done that way?

May be... you can have:
int[] dblLoanAmount = {7, 15, 30};
and use it indexed when you need it

This post has been edited by pbl: 11 November 2008 - 07:16 PM

Was This Post Helpful? 0
  • +
  • -

#19 cpeachy1223   User is offline

  • D.I.C Head

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

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 09:50 PM

View Postpbl, on 10 Nov, 2008 - 08:47 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 08:26 PM, said:

[LOL pbl.........yes I am a she ;) and I will check into the oops!

What oops ?
Happy to know that you are a she :)
OK there must be a play of words here that I can't understand, due to my lack of knowledge of the Shakespeare language ...
May be you are offering me a show on your Webcam and I don't understand your message :D
Seriously... still due to my understanding of Shakespeare
OK..I fixed the dblLoanAmount and set it to 200000. Now for the dblLoanDuration how is it best to hard code that in the duration is 3 different numbers 7, 15, 30. Which would be the easiest to go without changing a bunch of things around or can it be done that way?

May be... you can have:
int[] dblLoanAmount = {7, 15, 30};
and use it indexed when you need it


your talking about an Array? If so I can try it and index it let you know.
Was This Post Helpful? 0
  • +
  • -

#20 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 09:54 PM

Oups... a lot of concurent posting here
So where are we at ?

Can we see a copy of the latest code
ANd what the questins are ?
Was This Post Helpful? 0
  • +
  • -

#21 cpeachy1223   User is offline

  • D.I.C Head

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

Re: Mortgage Calculator with Graph

Posted 10 November 2008 - 10:10 PM

View Postcpeachy1223, on 10 Nov, 2008 - 08:50 PM, said:

View Postpbl, on 10 Nov, 2008 - 08:47 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 08:26 PM, said:

[LOL pbl.........yes I am a she ;) and I will check into the oops!

What oops ?
Happy to know that you are a she :)
OK there must be a play of words here that I can't understand, due to my lack of knowledge of the Shakespeare language ...
May be you are offering me a show on your Webcam and I don't understand your message :D
Seriously... still due to my understanding of Shakespeare
OK..I fixed the dblLoanAmount and set it to 200000. Now for the dblLoanDuration how is it best to hard code that in the duration is 3 different numbers 7, 15, 30. Which would be the easiest to go without changing a bunch of things around or can it be done that way?

May be... you can have:
int[] dblLoanAmount = {7, 15, 30};
and use it indexed when you need it


your talking about an Array? If so I can try it and index it let you know.


OK I am trying it pbl....but must being doing it wrong.........this is the error I am now getting:
C:\Assignment Programs Made Java 2\MortgageCalculator5.java:164: operator * cannot be applied to int[],int
double xincrement = (width/(dblLoanDuration*12));
^
1 error

Tool completed with exit code 1

  public void paint(Graphics g)
		{

	DecimalFormat paymentFormat = new DecimalFormat ("$0.00");

	int[] dblLoanDuration = new int[3];
	dblLoanDuration[0] = 7;
	dblLoanDuration[1] = 15;
	dblLoanDuration[2] = 30;

			int dblLoanAmount = 200000;
			boolean drawn;
			double width = 900.00;
			int height= 400;
			double x=1.0;
			double y=0.0;
			int counter = 0;
			double xincrement = (width/(dblLoanDuration*12));
			double yincrement = height/dblLoanAmount;

			g.drawString("Payments", 65, 10);
			while (counter <= 10) {
				x = x + xincrement;
				g.drawString(Integer.toString((int)((((dblLoanDuration[0]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				g.drawString(Integer.toString((int)((((dblLoanDuration[1]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				g.drawString(Integer.toString((int)((((dblLoanDuration[2]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				counter++;
				drawn = true;
			}

			double amount=dblLoanAmount;
			double payment=amount/12;
			g.drawString("Amount", 0, 20);
			while (y < height) {
				y = y + (height/12);
				g.drawString(paymentFormat.format(amount), 0, (int)y);
				amount = amount-payment;
		}
}


This is the only section I changed! I probably got it all screwed up!
Was This Post Helpful? 0
  • +
  • -

#22 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Mortgage Calculator with Graph

Posted 11 November 2008 - 07:18 PM

View Postcpeachy1223, on 10 Nov, 2008 - 09:10 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 08:50 PM, said:

View Postpbl, on 10 Nov, 2008 - 08:47 PM, said:

View Postcpeachy1223, on 10 Nov, 2008 - 08:26 PM, said:

[LOL pbl.........yes I am a she ;) and I will check into the oops!

What oops ?
Happy to know that you are a she :)
OK there must be a play of words here that I can't understand, due to my lack of knowledge of the Shakespeare language ...
Seriously... still due to my understanding of Shakespeare
OK..I fixed the dblLoanAmount and set it to 200000. Now for the dblLoanDuration how is it best to hard code that in the duration is 3 different numbers 7, 15, 30. Which would be the easiest to go without changing a bunch of things around or can it be done that way?

May be... you can have:
int[] dblLoanAmount = {7, 15, 30};
and use it indexed when you need it


your talking about an Array? If so I can try it and index it let you know.


OK I am trying it pbl....but must being doing it wrong.........this is the error I am now getting:
C:\Assignment Programs Made Java 2\MortgageCalculator5.java:164: operator * cannot be applied to int[],int
double xincrement = (width/(dblLoanDuration*12));
^
1 error

Tool completed with exit code 1

  public void paint(Graphics g)
		{

	DecimalFormat paymentFormat = new DecimalFormat ("$0.00");

	int[] dblLoanDuration = new int[3];
	dblLoanDuration[0] = 7;
	dblLoanDuration[1] = 15;
	dblLoanDuration[2] = 30;

			int dblLoanAmount = 200000;
			boolean drawn;
			double width = 900.00;
			int height= 400;
			double x=1.0;
			double y=0.0;
			int counter = 0;
			double xincrement = (width/(dblLoanDuration*12));
			double yincrement = height/dblLoanAmount;

			g.drawString("Payments", 65, 10);
			while (counter <= 10) {
				x = x + xincrement;
				g.drawString(Integer.toString((int)((((dblLoanDuration[0]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				g.drawString(Integer.toString((int)((((dblLoanDuration[1]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				g.drawString(Integer.toString((int)((((dblLoanDuration[2]*12)/10)*counter))), (int)((width/10)*counter)+55, 20);
				counter++;
				drawn = true;
			}

			double amount=dblLoanAmount;
			double payment=amount/12;
			g.drawString("Amount", 0, 20);
			while (y < height) {
				y = y + (height/12);
				g.drawString(paymentFormat.format(amount), 0, (int)y);
				amount = amount-payment;
		}
}

As dblLoanDuration is an Array you cannot use it in a calculation without indexing it

This is the only section I changed! I probably got it all screwed up!


double xincrement = (width/(dblLoanDuration*12));

should be

double xincrement = (width/(dblLoanDuration[something]*12));
Was This Post Helpful? 0
  • +
  • -

#23 Guest_Mel*


Reputation:

Re: Mortgage Calculator with Graph

Posted 04 May 2010 - 11:42 AM

What did you do to resolve these errors?

MortgageCalculator5.java:160: variable dblLoanDuration might not have been initialized
double xincrement = (width/(dblLoanDuration*12));
MortgageCalculator5.java:161: variable dblLoanAmount might not have been initialized
double yincrement = height/dblLoanAmount;
Was This Post Helpful? 0

#24 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2975
  • View blog
  • Posts: 11,224
  • Joined: 15-July 08

Re: Mortgage Calculator with Graph

Posted 04 May 2010 - 08:00 PM

In this case, they gave them initial values:
http://www.dreaminco...post__p__461390
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2