Firstly, when posting code, wrap the code in [code] [/code] tags. This makes reading the code easier, as it preserves indentation. (=
Secondly, the error is caused by the fact that total was not assigned an initial value.
The code declares total, but later tries to add to it's current value (by +=) without it ever having been given a defined initial value.
If you change
to
Code:
float total = 0.0F;
that will solve the error.