>I have looked over the code many many times but I am not sure where the fault is as >the solution comes up as "NaN." I have not shown constants in the code: >
Ok, so debugging is hard. But no one said programming is easy. So you should first do as you have done, which is code inspection, no computers. Make a nice clean print out of the code, have a red pen in you hand, put the listing in front of you, and read the code and make sure it is correct. Think about the logic, see if it all flows as expected, etc...
When this does not help, the next step is to use the debugger.
Make break points, step into the code, until you see the problem show up.
It is hard work, but this is programming. debugging is part of programming, asking someone else to debug your code for you will not help you learn how to do it.