Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Java Math

Tags:

java

math

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); 
   }
}
like image 218
user2499376 Avatar asked Dec 13 '25 23:12

user2499376


1 Answers

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.

like image 175
Matt Clark Avatar answered Dec 16 '25 12:12

Matt Clark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!