This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes converting inputted string number to double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "converting inputted string number to double" Watch "converting inputted string number to double" New topic
Author

converting inputted string number to double

mommy6
Greenhorn

Joined: Jun 20, 2001
Posts: 2
how do I convert a string number inputted w/JOptionPane.showInputDialog into a double?
String rate;
double hrRate;
rate = JOptionPane.showInputDialog("Enter hourly rate:");
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
mommy6
1st you're going to have to change your name to comply with the naming rules of the ranch. http://www.javaranch.com/name.jsp
2nd
to convert your string to a double use the parseDouble() mehtod from the Double class. Something like this should do it for you:

hope that helps
Dave


Dave
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Try the Double class!

Manfred.
mommy6
Greenhorn

Joined: Jun 20, 2001
Posts: 2
sorry-I will change my name-Thanks for the help!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: converting inputted string number to double