Properly receiving user input and checking for invalid inputs.
final version recognizes numbers up to (not including) 1 billion).