• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting inputted string number to double

 
mommy6
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the Double class!

Manfred.
 
mommy6
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry-I will change my name-Thanks for the help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic