Can some one with more Java exspirience help

This is a School assingment that I just cannot get my mind around, as follows

•      Write a Java program without a graphical user interface that calculates and displays the mortgage payment amount given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage.  In this program, hard code the amount = $200,000, the term = 30 years, and the interest rate = 5.75%.   You will need to find out how to calculate a mortgage payment given these variables.

what I have so far

public class CompMortgage
{
      //Main method

      public static void main (String[] args)
      {


            p = 200000;
            double i = 5.75;
            y = 30;
            h = (i/(12*100));
            n = y*12;
            t = 0;
            double m = p*(h/(1-(1+h)^-n));

            //Calculate monthly payment
            System.out.println("Calculate mortgage payment");

            double monthlyPayment = p*(h/(1-(1+h)^-n));

            //results

            System.out.printIn("The Monthly Payment Is" + monthlyPayment);
     }
 }

Any Help would be appriciated
1blkls1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BogoJokerCommented:
Hi 1blkls1,

Homework is not normally encouraged, but I will give you a tip.  Define the data type for the variables.  Just putting p=200000 will do nothing.  You need to define it, is it an int? double? long? float? String?  Object? Integer? I expect an int/double since your final answer seems to be a double.  Second, and finally, your monthlyPayment expression uses ^ -n.  The ^ character probably meaning to the power of, which is not defined as ^ in java, or in any language that I know of but scripts in excel and other programs.  You should use a predifined function in the Math class.  Check out the java documentation for the Math class at the Java 1.5 API docs:
http://java.sun.com/j2se/1.5.0/docs/api/
Search for Math under all classes then look for a function for "power"

Hope this helps,
Joe P
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
1blkls1Author Commented:
Thanks Joe
0
BogoJokerCommented:
Did you arrive at a solution?
I would like to see your final code, I might suggest some things to make it cleaner/better.
Joe P
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

1blkls1Author Commented:
No I won't have a chance to compleate it today,I have to go to work but I will post it tommorro morning when I get in.
0
1blkls1Author Commented:
What I came up with Still won't work

public class StaticCompMortgage
{
      //Main method

      public static void main (String[]args)
      {

            double p = 200000.00;// principal
            double i = 5.75;// annual interest
            double m = 360;// lenght in months
            double y = 30;//term in years
                      double j = i/(12*100);




            //Calculate monthly payment
            System.out.println("Calculate mortgage payment");

            double MonthlyPayment = double p*(j/(1-Math.pow(1+j)-1));


            //results

            System.out.printIn("MonthlyPayment");
     }
 }
0
BogoJokerCommented:
Well.  Printing out your results should be:
System.out.println("Monthly Payment is: " + MonthlyPayment);

Try that, the rest looks okay to me.
Joe P
0
1blkls1Author Commented:
This is what I have so far

public class CompMortgage
{
      //Main method

      public static void main (String[]args)
      {

            double p = 200000.00;// principal
            double i = 5.75;// annual interest
            double m = 360;// lenght in months
            double y = 30;//term in years
                      double j = i/(12*100);//monthly intrest in decimal form




            //Calculate monthly payment
            System.out.println("Calculate mortgage payment");

            double MonthlyPayment =  p *(i/12)/1-Math.pow(1+(i/12)-y);


            //results

            System.out.println("Monthly Payment is:" + MonthlyPayment);
     }
 }


I keep getting this error

C:\Documents and Settings\Phoenix\My Documents\JAV\CompMortgage.java:26: pow(double,double) in java.lang.Math cannot be applied to (double)
            double MonthlyPayment =  p *(i/12)/1-Math.pow(1+(i/12)-y);
                                                                                              ^
1 error

It seems to be pointing to the period , but I can't find anything wrong.

Tool completed with exit code 1
0
BogoJokerCommented:
I think what you want is:
double MonthlyPayment =  p *(i/12)/1-Math.pow(1+(i/12),-y);

That works for me.
Joe P
0
1blkls1Author Commented:
The missing comma, Thanks Joe.
0
1blkls1Author Commented:
What works

public class CompMortgage
{
      //Main method

      public static void main (String[]args)
      {

            double p = 200000.00;// principal
            double i = .0575;// annual interest
            int m = 360;// lenght in months
            int y = 30;//term in years
          double j = i/(12*100);//monthly interest in decimal form




            //Calculate monthly payment
            System.out.println("Calculate mortgage payment");

            double MonthlyPayment =  p *(i/12)/1-Math.pow(1+(i/12),-y);




            //results

            System.out.println("Monthly Payment is:" + MonthlyPayment);
     }
 }

The next challenge

Modify the mortgage program from Week 2 list the loan balance and interest paid for each payment over the term of the loan.  The list would scroll off the screen, but use loops to display a partial list, hesitate, and then display more of the list.  Do not use a graphical user interface.  Break calculations into at least three different methods.

I'll be working on this today and tommorro, Joe do you teach or tutor formally.
0
BogoJokerCommented:
Me? I'm a student, a Junior in college myself.
I do this in my spare time, work up some qualifications and stuff =)
Joe P
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.