No, you're inputting text. Your code is making incorrect assumptions. Try working with strings only and not worrying about conversion to int. Since you're using a switch to convert the "string" into hexadecimal anyway, it's not a big difference. For example with validating the input: