-1

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; }

ZyxeTV
  • 1

1 Answers1

0

create a method called startApplication() and copy the code from your main method, then when you get an exception, call the method again, put the method call in the else section.

Shahe
  • 964
  • 2
  • 13
  • 34