package io.macintosh.scratch.params;

public class MyMath {

	public int sum(int[] vals) {
		int sum = 0;
		for(int val : vals) {
			sum += val;
		}
		return sum;
	}

	public int avg(int[] vals) {
		int sum = sum(vals);
		int avg = sum / vals.length; // simple; no rounding
		return avg;
	}

}

@@ -200,31 +200,44 @@
 int 
-sum = sum(vals);%0A%09%09int 
+avg = 0;%0A%09%09if(vals.length %3E 0) %7B%0A%09%09%09
 avg 
@@ -241,16 +241,22 @@
 vg = sum
+(vals)
  / vals.
@@ -286,16 +286,20 @@
 ounding%0A
+%09%09%7D%0A
 %09%09return

Add protection for zero-length array.