Reputation: 59
So I know that this is super simple, and I'm sorry for having to ask this on here. Unfortuntely, I am confused and have no one else to ask...
Anyway, I'm trying to use Java to solve the following equation:
__________________
√ (3.1^17 + 2.7^11)
The code that I have right now doesn't work. It is:
public class Math
{
public static void main(String[] args)
{
double a = 3.1
double b = 2.7;
double c = Math.sqrt(Math.pow(a,17) + Math.pow(b,11));
System.out.println(c);
}
}
Upvotes: 2
Views: 1348
Reputation: 197
import java.lang.Math;
public class maths
{
public static void main(String[] args)
{
double a = 3.1;
double b = 2.7;
double c = Math.sqrt(Math.pow(a,17) + Math.pow(b,11));
System.out.println(c);
}
}
Upvotes: -1
Reputation: 28589
Your class name is Math, you are trying to call Math.function
, which does not exist in your class, you need to refactor
your class name and import the class library.
Right click the file name, Refactor > Rename
If your class must
be named math, you must call:
java.lang.Math.pow();
Another problem is that you are missing a ;
after:
double a = 3.1
Fix both of these problems and you will have a working code!
In the future, please post stack traces and specific problems are having.
Upvotes: 7