How did you try to debug it? I don't see many printlns statements to show the changes in the variables and the execution flow.
You need to print out everything so you can see what the computer sees. If you understand how the code is supposed to work, when you see what it is doing you should be able to change it so that it does what you want it to do.
Can you post the program's output and explain what is wrong with the output and show what the output should be.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16