Tuesday, 17 September 2013

After changing to a float: "Cannot confirm float from string"

After changing to a float: "Cannot confirm float from string"

Hey so here is my code:
if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(**Input > RandomNum**)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(if(repeat)
{
Guesses++;
String Input = JOptionPane.showInputDialog("Enter a number between 0
and 10. So far you have had " + Guesses + " guesses.");
Float.parseFloat(Input);
if(Input > RandomNum)
{
JOptionPane.showMessageDialog(null, "Too small.");
}
else if(Input = RandomNum)
{)
(This is just part of it) The Text with the **'s is where I get the error.
It says
The operator > is undefined for the argument type(s) String, float
Although I (think) I changed the Input, to a float
(Float.parseFloat(Input);) So do you know what the problem is? (If this
has already been answered then can you give me a link?)

No comments:

Post a Comment