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

Please write this Java program as simple as possible and with comments throughou

ID: 3733219 • Letter: P

Question


Please write this Java program as simple as possible and with comments throughout explaining what is happening. Thank you! Exercise 2: Design and implement a Java program for programming exercise 8.10, page 309 (name it LargestRowColumn). The program randomly fills in Os and 1s into a 4-by-4 matrix, prints the filled matrix, and then finds the first row and first column with the most 1s. Notice there could be other rows and columns the most 1s. We just need to find the first row and first column with the most 1s. Format your output following the given sample run. Design the main method of your program to handle all output and to allow the user to re-run the program to generate a different 4-by-4 matrix. Document your code and organize the output using appropriate formatting techniques

Explanation / Answer

/* * You can use Random library of java to generate random numbers * * To find row/col numbers: * * Find min row no; * 1. Declare variable to store row no and number of max one * 2. int rowNo=0,maxOne=0; * 3. Iterate over each row => for (row=0;row maxOne , update maxOne=count and update rowNo * * * We can do same for column separatly * * Sample Output: 0 0 0 1 1 0 0 1 0 1 1 0 0 1 0 1 The largest row index: 1 The largest column index: 3 * * */ //Please create MaxOne.java and copy code from below line to the end of answer import java.util.Random; public class MaxOne { //main method public static void main(String[] args) { //Declaring matrix of 4x4 int[][] matrix=new int[4][4]; //Instantiating Random() to generate random numbers Random random=new Random(); //Filling with 0 or 1 by generating 0 and 1 randomly for(int row=0;row