Add exception for invalid number.You seems to be using C syntax for printf, check out System.out.printlnAPI