AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New to java

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
nyy
Guest





PostPosted: Sat May 14, 2005 9:52 pm    Post subject: New to java Reply with quote



I have a problem with this program, this is a mortgage calculator,
there is no way I can make it work. No gui, this is a simple calculator
for a java class. Please anybody can help. Thx


public class MtgCalculator

{
public static void main(String[] args)
{
double monthlyPayment;
double interest=5.75;
double principleValue=200000.00;
double montInterest;
int years=30;
int months;
}
//DecimalFormat result=new DecimalFormat("$0.00")

// Formulas used in the calculation of the monthly payment

months=years*12;
montInterest=interest/1200;
monthlyPayment=(principleValue­*montInterest)/(1-Math.pow(1+
montInterest, -months));





// Information that will be printed out on the screen
{
System.out.println("** Mortgage Calculator **");
System.out.println("");
System.out.println(" For a $200,000 mortgage");
System.out.println(" Term= 30 years");
System.out.println(" Interest rate= 5.75%");
System.out.println(" The Payment Amount for this Loan is "
+(monthlyPayment));
}
}

Back to top
Jeffrey Spoon
Guest





PostPosted: Sat May 14, 2005 11:21 pm    Post subject: Re: New to java Reply with quote



In message <1116107572.879952.13760 (AT) f14g2000cwb (DOT) googlegroups.com>, nyy
<jet800 (AT) yahoo (DOT) com> writes
Quote:
I have a problem with this program, this is a mortgage calculator,
there is no way I can make it work. No gui, this is a simple calculator
for a java class. Please anybody can help. Thx


The structure of your class is a bit wonky.

You've put your variables in main, yet your actual code is not in the
main method, or in a method at all. It will never execute unless you put
it in a method and call that method, or put it in the main method (which
is always executed first). I put it all in main, just to keep it
simple:

However I changed:
monthlyPayment=(principleValue­*montInterest)/(1-Math.pow(1+montInterest,
-months));
by taking out the '-' out because you can't do' -*'. I'm not sure what
you're trying to do there but you can't subtract and multiply at the
same time in that way. So the result might not be quite right, depending
on what you're trying to do.

This compiles and runs though:


public class MtgCalculator

{

double monthlyPayment;
double interest=5.75;
double principleValue=200000.00;
double montInterest;
int years=30;
int months;


public static void main(String[] args)
{


double monthlyPayment;
double interest=5.75;
double principleValue=200000.00;
double montInterest;
int years=30;
int months;





months= years*12;
montInterest= interest/1200;
monthlyPayment = (principleValue * montInterest)/(1-Math.pow(1+
montInterest, - months));
System.out.println("** Mortgage Calculator **");
System.out.println("");
System.out.println(" For a $200,000 mortgage");
System.out.println(" Term= 30 years");
System.out.println(" Interest rate= 5.75%");
System.out.println(" The Payment Amount for this Loan is
" +(monthlyPayment));

}
//DecimalFormat result=new DecimalFormat("$0.00")

// Formulas used in the calculation of the monthly payment



// Information that will be printed out on the screen



}



--
Jeffrey Spoon


Back to top
nyy
Guest





PostPosted: Mon May 16, 2005 4:28 pm    Post subject: Re: New to java Reply with quote



Thanks Jeffrey, I tried to complied but it gave me 6 errors. I don't
know men, I only have until wednesday to turin this program in. If you
can take a look, I appreciate. Thx

Back to top
nyy
Guest





PostPosted: Mon May 16, 2005 4:28 pm    Post subject: Re: New to java Reply with quote

Thanks Jeffrey, I tried to complied but it gave me 6 errors. I don't
know men, I only have until wednesday to turin this program in. If you
can take a look, I appreciate. Thx

Back to top
nyy
Guest





PostPosted: Mon May 16, 2005 4:28 pm    Post subject: Re: New to java Reply with quote

Thanks Jeffrey, I tried to complied but it gave me 6 errors. I don't
know men, I only have until wednesday to turin this program in. If you
can take a look, I appreciate. Thx

Back to top
Jeffrey Spoon
Guest





PostPosted: Mon May 16, 2005 4:57 pm    Post subject: Re: New to java Reply with quote

In message <1116260914.318869.119700 (AT) g49g2000cwa (DOT) googlegroups.com>, nyy
<jet800 (AT) yahoo (DOT) com> writes
Quote:
Thanks Jeffrey, I tried to complied but it gave me 6 errors.

What are they? Worked fine on 1.4.1.03



--
Jeffrey Spoon


Back to top
nyy
Guest





PostPosted: Mon May 16, 2005 6:53 pm    Post subject: Re: New to java Reply with quote

Never mind, I had some little misplace commas in it, it is working but,
I am trying to round the long number from the monthly payment to two
decimal points. Any suggestion. Thx.

Back to top
NYY
Guest





PostPosted: Fri May 20, 2005 3:09 am    Post subject: Re: New to java Reply with quote

hello Jeffrey, my program ran good. Now, I am scrathing myself how to
calculate the mortgage payment and display the balance and interest
paid for the 30 yrs. Here is my program, how would you do that if you
can help me. Thx



import java.text.DecimalFormat;

//Give the program a name
public class MtgCalculator
{
public static void main(String[] args)
{
//Declare variables to calculate the mortgage monthly payment
double monthlyPayment;
double interest=5.75;
double principleValue=200000.00;
double montInterest;
int years=30;
int months;
months= years*12;
montInterest= interest/1200;
DecimalFormat result=new DecimalFormat("$0.00"); //Declare
DecimalFormat to display two decimal points

//Formula for calculating mortgage monthly payment
monthlyPayment = (principleValue * montInterest)/(1-Math.pow(1+
montInterest, - months));

//Display result for the mortgage monthly payment
System.out.println("** Mortgage Calculator **");
System.out.println(" YB Creations@2005 ");
System.out.println("");
System.out.println(" For a $200,000.00 mortgage");
System.out.println(" Term= 30 years");
System.out.println(" Interest rate= 5.75%");
System.out.println (" The Monthly Payment Amount for this Loan is "
+result.format(monthlyPayment));
}
}

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.