Added try-catch blocks to check if number is entered.