So, as the title says I'm trying to create a program using isNumber. It's supposed to tell you if the input is written with numbers or not obv... but also if the input isn't in number form it is not supposed to end the program basically just start it over again. (I'm quite new to programming) Thx in advance. This is how far I've gotten
String input = JOptionPane.showInputDialog("Skriv in ett tal i sifferform");
if(isNumber(input))
{
JOptionPane.showMessageDialog(null, "Godkänt, du skrev in ett tal i sifferform");
}
else
{
JOptionPane.showMessageDialog(null, "Du har ej skrivit in ett tal i sifferform");
}
}
public static boolean isNumber(String in)
{
try
{
Double.parseDouble(in);
return true;
}
catch (Exception e)
{
return false;
}