• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i change this piece of code from a double to a stirng

 
Kristen hulaj
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing this for a school project and would like the user to be able to enter in yes if they would like to view the instructions if they would like. i have the rest of the program working but right now it is just letting them enter a number and i can not find out how to let them input a word without errors.


public void actionPerformed(ActionEvent e)
{
Double name, instructions;
name = Double.parseDouble(nameTF.getText()); //We use the getText & setText methods to manipulate the data entered into those fields.
instructions = Double.parseDouble(instructionsTF.getText());


}
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a strange UI idea - entering "yes" for boolean decision. The proper way if for the user to click a checkbox, the label of which says "view instructions" or some such.
 
John Mejia
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try a string compare,
if( answer == "yes") then myNumber = 1 else myNumber = 0

Something like that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic