1. ## Getting an Error!

I am not exactly sure whats the case is but I am getting a syntax sort of error:

temp = (1.0/(pow(x,y)));
^
in this line

Java Code:
```import java.util.Scanner;
import java.text.DecimalFormat;
import java.lang.Math;

public class Finance {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Principal Amount: ");
double Principal_Amount = input.nextDouble();

System.out.print("Term of Mortgage in Years: ");
double Term_Mortgage = input.nextDouble();

System.out.print("Interest Rate: ");
double Interest = input.nextDouble();

double payment, r, temp, x, y, future_value, interest_charged;
r = Interest/100.0;
x = 1.0+r/12.0;
y = Term_Mortgage * 12.0;
temp = (1.0/(pow(x,y)));
payment = (Principal_Amount*r/12.0)/(1-temp);
future_value = payment * Term_Mortgage * 12.0;

interest_charged = future_value - Principal_Amount;

System.out.println("Principal: \$" + Principal_Amount);
System.out.println("Future Value: \$"+future_value);
System.out.println("Terms of Loans in Years :" +Term_Mortgage);
System.out.println("Interest Rate :" +Interest);
System.out.println("Interest Charged :" +interest_charged);
System.out.println("Payment: "+payment);

}
}```
Thanks
Last edited by racewithferrari; 09-08-2012 at 07:30 AM. Reason: formatting  Reply With Quote

2. Senior Member Join Date
Apr 2010
Location
Philippines
Posts
580
Rep Power
11

## Re: Getting an Error!

Post what is the syntax error?  Reply With Quote

3. ## Re: Getting an Error!

db  Reply With Quote

4. Member Join Date
Sep 2012
Location
Bangalore,India
Posts
1
Rep Power
0

## Re: Getting an Error!

problem:The method pow(double,double) is undefined for the type Finance
solution:To fix this you have to create method 'pow(double,double)'
Try this code below best of luck dear

import java.util.Scanner;
import java.text.DecimalFormat;
import java.lang.Math;

public class Finance {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Principal Amount: ");
double Principal_Amount = input.nextDouble();

System.out.print("Term of Mortgage in Years: ");
double Term_Mortgage = input.nextDouble();

System.out.print("Interest Rate: ");
double Interest = input.nextDouble();

double payment, r, temp, x, y, future_value, interest_charged;
r = Interest/100.0;
x = 1.0+r/12.0;
y = Term_Mortgage * 12.0;
temp = (1.0/(pow(x,y)));
payment = (Principal_Amount*r/12.0)/(1-temp);
future_value = payment * Term_Mortgage * 12.0;

interest_charged = future_value - Principal_Amount;

System.out.println("Principal: \$" + Principal_Amount);
System.out.println("Future Value: \$"+future_value);
System.out.println("Terms of Loans in Years :" +Term_Mortgage);
System.out.println("Interest Rate :" +Interest);
System.out.println("Interest Charged :" +interest_charged);
System.out.println("Payment: "+payment);

}

private static double pow(double x, double y) {
return 0;
}
}  Reply With Quote

5. ## Re: Getting an Error!

BB Code List - Java Programming Forum

Try this code below
Don't spoonfeed. That denies the questioner of a learning opportunity and is not considered helpful.

db  Reply With Quote

6. Member Join Date
Jun 2012
Location
Austria
Posts
1
Rep Power
0

## Re: Getting an Error!

Hey,

your problem is that your class Finance doesn't have a method called pow.
I see that you imported the Math class. That's good. It means that you know, that the pow method is in that class.

Now - your mistake here is that you need Java to tell, which pow method to call. Since the pow method within the Math-class is static (see the API: Math (Java Platform SE 6)) you have to call it statically.
Classes are not really like libraries in C or C++ for instance. You can't just import one and then access it's methods. You either have to instantiate a class (i.e. by calling new) - or, if applicable - call the desired method statically.

Hope this helps, don't want to just give you the example, since that would rob you of a (great) "aha"-moment.  Reply With Quote

error, free lottery, money, syntax 