So i have a problem with a little program...
I always get the error message: " error 'else' without 'if' ".
I searched in the forums here but I didn't found a solution for that because the fix always was just to remove a semicolon behind a condition. But I don't use a semicolon behind a condition.
import javax.swing.JOptionPane;
public class TypeInNumber {
public static void main (String [] args) {
int number;
String hellodude = "This is a message for you dude";
JOptionPane.showMessageDialog(null, hellodude);
number = Integer.parseInt(JOptionPane.showInputDialog("Type in a number between 0 and 10:"));
while (number<0 || number>10) {
JOptionPane.showMessageDialog(null, "You typed in a number, that wasn't allowed to type in");
number=Integer.parseInt(JOptionPane.showInputDialog("Type in a number between 0 and 10:"));
} else {
JOptionPane.showMessageDialog(null, "You are an amazing winner dude");
}
}
}
Aucun commentaire:
Enregistrer un commentaire