Calculate average in java

Just some minor modification to your code will do (with some var renaming for clarity) : Note that the loop can also be simplified: Edit: the OP seems to want to use the args array. This seems to be a String array, thus updated the answer accordingly. Update: As zoxqoj correctly pointed out, integer/double overflow is not … Read more