Results 1 to 6 of 6
Thread: Getting an Error!
 09082012, 07:29 AM #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)/(1temp); 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); } }
Last edited by racewithferrari; 09082012 at 07:30 AM. Reason: formatting
 09082012, 07:55 AM #2Senior Member
 Join Date
 Apr 2010
 Location
 Philippines
 Posts
 580
 Rep Power
 11
Re: Getting an Error!
Post what is the syntax error?
 09082012, 09:42 AM #3
Re: Getting an Error!
Learn to follow the Java coding conventions. Variable names start with a lowercase letter.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 09082012, 10:35 AM #4Member
 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)/(1temp);
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;
}
}
 09082012, 01:58 PM #5
Re: Getting an Error!
BB Code List  Java Programming Forum
Try this code below
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 09082012, 02:17 PM #6Member
 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 Mathclass 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.
Similar Threads

java.lang.NullpointerException error in tomcat 5.5 / http status 500 error
By rahil in forum Apache CommonsReplies: 3Last Post: 05082012, 05:26 PM 
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03102010, 01:53 PM 
Thread: Error 500Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12052009, 07:28 AM 
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10262009, 04:38 PM
Bookmarks