Hi there, can anyone help me to validate the input value? example when i pressed character on the keyboard it will ask us to press number only.. anyone got any idea how to validate it?
thanks in advance...
import javax.swing.*; public class additiontutor { public static void main(String args[]) { int number1 = (int)(System.currentTimeMillis() % 10); int number2 = (int)(System.currentTimeMillis() * 7 % 10); String answerString = JOptionPane.showInputDialog ("What is " + number1 + " + " + number2 + "?"); int answer = Integer.parseInt(answerString); JOptionPane.showMessageDialog(null, number1 + " + " + number2 + " = " + answer + " is " + (number1 + number2 == answer)); } }