Obviously, your own code is like a blackbox to you. It don't do what you expect, and you don't understand why.
What follow is not directly a solution to your problem, but a key that will help you to understand by yourself what is wrong.
The debugger is your friend. It will show you what your code is really doing.
Follow the execution, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
Debugger - Wikipedia, the free encyclopedia[
^]
Pay attention to :
- you calculate the "average", where do you save it ?
- you display an "average", where does it come from ?
- does it match ?
-Check how you calculate the average.
Quote:
I've tried several corrections to debug this code but nothing is working.
Never try random corrections to see if it work, it is a waste of time, it is better to use a debugger and compare what you see with what you expect.