• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with string to double conversion

 
Brent Geeeee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey im doing a program i cant get right,

first im trying to get input and convert it to a double value
im using the JOptionPane.showDialog for the input,

second wat symbol do u use for the square root of or the square of something in an equation?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First to convert a String to a double you can use Double.parseDouble.

The class java.lang.Math has methods for taking the square root and square.

There is no symbol for square root or square.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Brent Geeeee,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names.

You can edit your name here. Thank you for your prompt attention!

-Marc

PS: As Keith said, there are no Java operators for squares or roots, so do NOT make the mistake of using the bitwise "exclusive or," as in x^2. Instead, you should use methods in the Math class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic