Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java class Fil with a method fel that takes atwo-dimensional integer arr

ID: 3618962 • Letter: W

Question

Write a Java class Fil with a method fel that takes atwo-dimensional integer array arr and returns a one-dimensional array firs. The array firsconsists of the averages of rows in array arr; that is, the i-th entry of firs is the averageof (i,j)-th entries of arr (here j is any integer from j=0 to j=arr[i].length - 1). The methodshould be applied to array fff = {{2,3}, {5,3,1}, {4,1,5,6}, {1,3}}. Hint: The resulting array will be firs = {2.5, 3.0, 4.0,2.0}.

THIS IS THE ANSWER OF THE CLASS, PLEASE EXPLAIN LINE BY LINEEACH OF THE MAIN METHOD AND ALSO THE METHOD DOUBLE NICE AND CLEAR LIFESAVER POINTS TO BE GIVEN
public class Fil{ public static void main(String[] args){ int[][] fff={{2,3}, {5,3,1},{4,1,5,6},{1,3}}; double[] firs=fel(fff); for (int i=0; i<firs.length; i++) System.out.print(firs[i]+" "); System.out.println(); } public static double[] fel(int[][] arr){ double[] ttt=new double[arr.length]; double a=0.0; for (int i=0; i<arr.length;i++){ for (int j=0; j<arr[i].length;j++){ ttt[i]=ttt[i]+arr[i][j];} ttt[i]=ttt[i]/arr[i].length; } return ttt; } }
Write a Java class Fil with a method fel that takes atwo-dimensional integer array arr and returns a one-dimensional array firs. The array firsconsists of the averages of rows in array arr; that is, the i-th entry of firs is the averageof (i,j)-th entries of arr (here j is any integer from j=0 to j=arr[i].length - 1). The methodshould be applied to array fff = {{2,3}, {5,3,1}, {4,1,5,6}, {1,3}}. Hint: The resulting array will be firs = {2.5, 3.0, 4.0,2.0}.

THIS IS THE ANSWER OF THE CLASS, PLEASE EXPLAIN LINE BY LINEEACH OF THE MAIN METHOD AND ALSO THE METHOD DOUBLE NICE AND CLEAR LIFESAVER POINTS TO BE GIVEN
public class Fil{ public static void main(String[] args){ int[][] fff={{2,3}, {5,3,1},{4,1,5,6},{1,3}}; double[] firs=fel(fff); for (int i=0; i<firs.length; i++) System.out.print(firs[i]+" "); System.out.println(); } public static double[] fel(int[][] arr){ double[] ttt=new double[arr.length]; double a=0.0; for (int i=0; i<arr.length;i++){ for (int j=0; j<arr[i].length;j++){ ttt[i]=ttt[i]+arr[i][j];} ttt[i]=ttt[i]/arr[i].length; } return ttt; } }

Explanation / Answer

public class Fil{ public static void main(String[] args){ int[][] fff={{2,3}, {5,3,1},{4,1,5,6},{1,3}}; double[] firs=fel(fff); for (int i=0; i<firs.length; i++) System.out.print(firs[i]+" "); System.out.println(); } public static double[] fel(int[][] arr){ double[] ttt=new double[arr.length]; double a=0.0; for (int i=0; i<arr.length;i++){ for (int j=0; j<arr[i].length;j++){ ttt[i]=ttt[i]+arr[i][j];} ttt[i]=ttt[i]/arr[i].length; } return ttt; } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote