Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Mortgage Amortization calculator

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Marshal
Posts: 14070
234
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you have a question about this code?
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nicely formatted code.
Do you have a question associated with it? Other than "It doesn't work" ?


Your first problem is probably on line 73. Compare the format strings on line 73 with that on line 74

The other thing to be wary of is your variables.
You define interesetMonth as a class variable, and interestMonth in your calAmort method. Getting rid of those 'global' variables might make it better.




 
Thomas Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I do, thank you. When I run my code I'm not getting the correct output. I have searched for a fix but, I'm stuck, I can input my numbers but I'm not getting a amortization I know I'm missing something I just can't figure out what.
 
Thomas Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So Mr. Evans your saying take my private double interestMonth out of my code? And I see what your saying about line 73.
 
Thomas Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fix lined 73 and this was my output???

Enter amount of loan65000
Enter interest rate per year
5.2
Enter number of years
30

Amortization Schedule for Borrower
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
old Month Interest Principle New Balance


Month Balance Payment Paid Paid Balance


1 65000.000 65000.000 0.000 65000.000 0.000
 
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thomas Johnson wrote:Yes I do, thank you. When I run my code I'm not getting the correct output. I have searched for a fix but, I'm stuck, I can input my numbers but I'm not getting a amortization I know I'm missing something I just can't figure out what.



Your first problem is with spelling. Make sure all your variables are spelled the same way.

The second problem is more subtle and it has to do with scope. In general, declare your variables as near to where they are used as possible.

Fixing the first problem will make your program run, and fixing the second problem will make it a better program.
 
Knute Snortum
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thomas Johnson wrote:I fix lined 73 and this was my output???

Enter amount of loan65000
Enter interest rate per year
5.2
Enter number of years
30

Amortization Schedule for Borrower
-
-
etc.



That's exactly what the for loop in printHeader is doing. What do you want it to do?
 
Thomas Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Knute I thought I made sure I had everything spelled correctly I will check my work.
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!