# public class Square int count double x1 x2 x3 error err foo static Dou

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41``` ```public class Square { int k, count; double x1, x2, x3, error, err, foo; static Double[] Val = new Double[5]; public Square(int k, double x1, double x2, double x3, double error){ this.k = k; this.x1 = x1; this.x2 = x2; this.x3 = x3; this.error = error; } private double fun(int k, double x){ switch (k) { case 1: foo = Math.sin(x); break; case 2: foo = x*x + 4; break; default: foo = Math.exp(x); } return Math.abs(foo); } public Double[] Method() { count = 0; Val[4] = 0.0; do { count ++; for (int i = 0; i < 4; i++) { Val[i] = 0.0; } for (double i = x1; i < x2; i += Input.x3) { Val[0] += ((i + error) - i) * fun(k, i); Val[1] += ((i + error) - i) * fun(k, ((i + error) + i) / 2); Val[2] += ((i + error) - i) * fun(k, (i + error)); Val[3]++; } Input.x3 *= 2; err = 1/3*Math.abs(Val[1] - err); } while((err > error) && (count <= 1)); Val[4] = err; return Val; } } ```