You want a user to input a number. You want to make sure it's a valid number, and give an error message if it isn't.
Put the user's input into a string variable. Test whether the variable has something that could be interpreted as a valid number. If so, convert the string into a number.
If a user enters text, and you try to store it into a numeric variable, your program may crash. Input the data into a string variable first. An example: