It doesn't work?
The first thing that springs to mind, is that you do no useful checking on what the user entered.
The second is that what happens if the first character entered is not a digit?
I strongly suggest that you learn to use the debugger.
Put a breakpoint on the line
while (i < input.length())
and single step it through, looking at the variables as you go. Before each step, you should have a good idea in you mind of what you expect to happen. Check it did. If not, why not? change your code, and try again. It is the only way you are going to learn.
I would suggest that you start by setting a known, static input string, rather than typing it each time - that way you can simplify the run and reduce the number of variables.