Your current code is a mixed up mess. I suggests that you delete all of it and start over.
Make a list of the simple steps the code must do for the task that you what it to do.
Make each statement in the list a simple statement.
For example:
prompt user to enter some input
read user's response
convert the input to ...
etc

When you have a list of the steps the program should do, then write the code for a step, compile it and test it.
When it works, add the code for the next step, compile it, test it and when it works, move on to the next.