1. You are resetting total to 0 every time you iterate through the loop
2. total is of type int. This means it only stores integers, not 0.5. Dividing total by something will result in truncation, not rounding. In other words, 0.99999999 will be truncated to 0.
3. I really can't be stuffed trying to decrypt weirdly formatted code, so I'll stop here.