Welcome to Dream.In.Code
Become a Java Expert!

Join 149,478 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,704 people online right now. Registration is fast and FREE... Join Now!




Basic Mortgage Program

 
Reply to this topicStart new topic

Basic Mortgage Program

nateknowles09
18 Apr, 2007 - 01:56 PM
Post #1

New D.I.C Head
*

Joined: 18 Apr, 2007
Posts: 7


My Contributions
Hi all,
I am really really new at this Java stuff. I just started taking a Object Oriented programming class and need some help.

The problem i am working on consists of a 30 year mortgage and my output needs to show the monthly payments with the loan amount of 100,000 - 200,000 with increments of 20,000 dollars. The interest rate is 6% - 10% with increments of 0.5%. I also have no idea what to put to get an output because i keep getting errors since i know my code is wrong.

I am really new at this stuff and whatever guidance and explainations you can give me will help a ton!

This is all i have so far:
CODE

class mortgage
{
     public static void main(String args[])
      {
            int Pa = (0);
           double[] iRate= {0.060, 0.065, 0.070, 0.075, 0.080, 0.085, 0.090, 0.095, 0.100};//interest rates//
           double amount[] = {100000, 120000, 140000, 160000, 180000, 200000};//*through $200,000(with increments of $20,000);
           int PPy = 12;
           int term= 30;//years for loan//
           int x = (1 + iRate / 12);
           Math.pow = (x,y);
           Rate = AnnualiRate / PPy;//PPy is payments per year, this  formula finds the real interest rate//
          Pa = (amount * iRate) / (1 - Math.pow(1 + iRate, - (term*PPy)));
   }
}

User is offlineProfile CardPM
+Quote Post

Ellie
RE: Basic Mortgage Program
19 Apr, 2007 - 01:02 AM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 427



Thanked: 4 times
Dream Kudos: 150
My Contributions

Is the program supposed to take input from a user as to the amount/interest rate etc? Otherwise you are going to have a kind of table output because you'll have 9 different interest rates, and 6 different loan amounts for each of them.

If it's an Object Oriented class, are you supposed to be using class variables, and methods etc, or is it ok just to use the main method to hold everything (because that's not very OO)?

Many of your variables in your program are not initialised, so that accounts for some of the errors, e.g. iRate, and AnnualiRate and also the 'y' value in your Math.pow(x, y) line.

User is offlineProfile CardPM
+Quote Post

nateknowles09
RE: Basic Mortgage Program
19 Apr, 2007 - 08:42 AM
Post #3

New D.I.C Head
*

Joined: 18 Apr, 2007
Posts: 7


My Contributions
Hi!

Actually my output is supposed to come out in some sort of table form.
For example:

Principal 6% 6.5% 7% 7.5% 8% 8.5% 9% 9.5% 10%
100000 600 632 665 699 733 768 804 840 877
120000 719 758 798 839 880 922 965 1009 1053
140000 … … … … … … … … …
160000 … … … … … … … … …
180000 … … … … … … … … …
200000 … … … … … … … … …


I knew my problem was initializing all my variables, i am confused on whether i use int or double, ect.

User is offlineProfile CardPM
+Quote Post

Ellie
RE: Basic Mortgage Program
19 Apr, 2007 - 09:51 AM
Post #4

D.I.C Regular
Group Icon

Joined: 17 Jan, 2007
Posts: 427



Thanked: 4 times
Dream Kudos: 150
My Contributions
I've just got another person's mortgage program working here:
Mortgage calculator. This should be a good start for you, as it seems to be a similar problem. You'll need to make the arrays larger to accomodate all your values etc, but it's a working program to start with. Keep posting if you still have problems though
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 03:26PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month