/** * Exercise 5.7 p 156
* Each of these method is an attempt to compute the average of 3 integers * as accurately as possible. None of them is correct. There are syntax and * logical errors. Find the error(s) in each one of them.
* Complete also the last method to display a number of hours as * hours, minutes and seconds. */ public class Exercise57 { public double average3A(int n1, int n2, int n3) { return (double)n1 + (double)n2 + (double)n3/3.0; } public double average3B(int n1, int n2, int n3) { double result; result = new ((n1+n2+n3)/3.0); return result; } public double average3C(int n1, int n2, int n3) { double result; result = (double)(n1+n2+n3)/3.0); return result; } public double average3D(int n1, int n2, int n3) { return (double(n1)+double(n2)+double(n3))/3; } /** * Extra pratice: display a number of hours as hh:mm:ss */ public void printAsHMS(double hours) { } }