I believe the issue is your for loop condition.

Example: user enters 7
First iteration, 7 % 10 >= 0, maxDigit = 7
Second iteration, 7 % 10 >= 7, maxDigit = 7 (you enter an infinite loop)