4 Replies - 1113 Views - Last Post: 08 September 2013 - 12:31 PM Rate Topic: -----

#1 twins2me   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 30-July 13

Need help writing a math formula in Java

Posted 08 September 2013 - 11:33 AM

I'm super new to java and I need help writing a math formula. I need to write "Area = ((3 * (sqrt(3))/2) * S(squared)"

I've seen the math.sqrt and the math.pow but don't know how to use them to write this formula. The S is input from the user.

Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: Need help writing a math formula in Java

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15571
  • View blog
  • Posts: 62,361
  • Joined: 12-June 08

Re: Need help writing a math formula in Java

Posted 08 September 2013 - 11:34 AM

Have you checked the documentation?

http://docs.oracle.c.../lang/Math.html
Was This Post Helpful? 0
  • +
  • -

#3 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: Need help writing a math formula in Java

Posted 08 September 2013 - 11:37 AM

Its really as simple as replacing sqrt etc with the relevant method call.

Also remember Java is case sensitive. math.pow is not the same as Math.pow

Also remember S^2 = S*S. There is not a lot of point using Math.pow to square a variable.

This post has been edited by Ryano121: 08 September 2013 - 11:38 AM

Was This Post Helpful? 1
  • +
  • -

#4 twins2me   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 30-July 13

Re: Need help writing a math formula in Java

Posted 08 September 2013 - 12:21 PM

Thank you both!
Was This Post Helpful? 0
  • +
  • -

#5 twins2me   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 30-July 13

Re: Need help writing a math formula in Java

Posted 08 September 2013 - 12:31 PM

It worked! Thanks so much. I had math.sqrt instead of Math.sqrt and had math.pow and changed it to S * S.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1