Create a class called Lab7b and in it implement all of the methods below. Also, write a main method with test calls to all of these methods. Don’t forget to turn in your file to Canvas before the end of the lab today.
int[][] random(int N, int start, int end) returns an N-by-N matrix of random integers ranging from start to end;
int rowSum(int[][] a, int i) returns the sum of the elements in row i of the 2-D array a;
int colSum(int[][] a, int j) returns the sum of the elements in column j of the 2-D array a;
boolean isSquare(int[][] a) returns true if the 2-D array a is square (i.e. the number of rows and columns are the same);
boolean isLatin(int[][] a) returns true if the 2-D array a is a Latin square (i.e. an n-by-n matrix such that each row and each column contains the values from 1 through n with no repeats);
main(String[] args): the main method should test each method above on five randomly generated matrices and also these ones:
int[][] allneg = { {-10,-12,-3}, {-4,-5,-6,-8}, {-7,-8} };
int[][] nonsquare ={ {1,2,3}, {4,5}, {6,7,8,9} };
int[][] latin = { {1,2,3}, {2,3,1}, {3,1,2} };
int[][] notlatin = { {2,1,3}, {2,3,1}, {3,1,2} };Note: The borders are produced at the time of printing. You also need to shift the numbers for each row of the 2D array as displayed below:
+-+-+-+-+-+
|1|2|3|4|5|
+-+-+-+-+-+
|2|3|4|5|1|
+-+-+-+-+-+
|3|4|5|1|2|
+-+-+-+-+-+
|4|5|1|2|3|
+-+-+-+-+-+
|5|1|2|3|4|
+-+-+-+-+-+




Program for ShiftNumbers.java
Create a class called Lab7b and in it implement all of the methods below. Also, write...
In Java Please Create A Program For The Following; Please Note: This program should be able accept changes to the values of constants ROWS and COLS when testing the codes. Switch2DRows Given a 2D array with ROWS rows and COLS columns of random numbers 0-9, re-order the rows such that the row with the highest row sum is switched with the first row. You can assume that 2D arrau represents a rectangular matrix (i.e. it is not ragged). Sample run:...
Submit Chapter7.java with four (4) public static methods as follows: A. Write a method called mostCommon that accepts an array of integers as its only parameter, and returns the int that occurs most frequently. Break ties by returning the lower value For example, {1,2,2,3,4,4} would return 2 as the most common int. B. Write mostCommon (same as above) that accepts an array of doubles, and returns the double that occurs most frequently. Consider any double values that are within 0.1%...
Write a class named RowSort which has the following members. Private: (1) double matrix 0O (a 2D array): (2) int columns; (3) int rows Public: (1) A default constructor that creates a 2D array, 8 6 4 (2) A constructor that takes three values for the three private members, and creates a 2D array accordingly. (3) The "get" and "set" methods for the three private members. (4) A method that displays a 2D array, stored in the private member matrix,...
Java
Here is the template
public class ShiftNumbers {
public static void main(String[] args) {
// TODO: Declare matrix shell size
// TODO: Create first row
// TODO: Generate remaining rows
// TODO: Display matrix
}
/**
* firstRow
*
* This will generate the first row of the matrix, given the size n. The
* elements of this row will be the values from 1 to n
*
* @param size int Desired size of the array
* @return...
Assignment is designed to develop your ability to create static methods and manipulate 1D and 2D arrays in Java. Create a single Java class Matrix and inside the class create the specified static methods as described Task # Description 1 Create a matrix (known components) 2 Create a matrix (random components) 3 Create a matrix from vectors 4 Compare two matrices 5 Add two matrices 6 Subtract two matrices 7 Multiply a matrix by a scalar 8 Multiply two matrices...
please answer in Java..all excercises. /** * YOUR NAME GOES HERE * 4/7/2017 */ public class Chapter9a_FillInTheCode { public static void main(String[] args) { String [][] geo = {{"MD", "NY", "NJ", "MA", "CA", "MI", "OR"}, {"Detroit", "Newark", "Boston", "Seattle"}}; // ------> exercise 9a1 // this code prints the element at row at index 1 and column at index 2 // your code goes here System.out.println("Done exercise 9a1.\n"); // ------> exercise 9a2 // this code prints all the states in the...
Can someone help me with this? Create a mini program including a main() method and void methods where arrays are nxn i.e. same no. of rows & columns 1. displayArray(): Takes one parameter, a 2D symmetrical int array called "symmetric" & print the array as shown in the sample output. 2. shiftTheRowsBelow(): Takes one parameter, a 2D symmetrical int array called "symmetric". It will take the given values in the last row of the array, move them to the first...
Please provide answer!
(10) 3. Develop a method called set2DArray that given an integer number N creates and returns a 2D array with N rows and N columns initialized as follows: All elements on diagonal: 1 All elements above diagonal: row# + Column# All elements below diagonal: row# - Column#
Write a C function bool arrayEqual that compares two 2D arrays. It accepts the following arguments int a[ROW][COL], int b[ROW][COL], m, n (m and n are the size of the rows and columns correspondingly). It returns true if all the corresponding elements are equal in a and b, otherwise false. Write the main function. Initialize two arrays (e.g. 3*4 dimension).
JAVA, Please do as asked and show solution/code clearly and let code ready to be copied: complete the remaining exercises as methods within that class Write a Java method that: - takes as input parameter a 2D array of numbers, with R rows and C columns - and fills the array following the next rule (for R = 3 and C = 5): [[1, 2, 3, 4, 5] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]] - print...