total must be initialized

total = 0.0;