Hi Nicholas,
Welcome to CodeRanch!
As Campbell has already mentioned, you need to make the code modular.
Apart from that, I haven't gone through all the code, but it will be much helpful if you
TellTheDetails(<-click) - that is - what is the input you gave, what was the expected output, what is actual output etc.
Also, you can try and put some extra print statements at intermediate steps (e.g. after calculating the sum etc.) to understand in which area the code is going wrong.
I hope this helps.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)