import java.util.Random;
import java.util.Scanner;
public class Array2d {
public static void display(int a[][]) {
for (int i = 0; i < a.length;
++i) {
System.out.println();
for (int j = 0;
j < a[0].length; ++j) {
System.out.print(a[i][j] + " ");
}
}
}
public static void tConverted(int t[][]) {
for (int i = 0; i < t.length;
++i) {
for (int j = 0;
j < t[0].length; ++j) {
if(t[i][j] < 0)
t[i][j] = -1;
else if(t[i][j] > 0)
t[i][j] = 1;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method
stub
int row, cols, row1, col1;
Scanner sc = new
Scanner(System.in);
System.out.println("Enter number of
rows: ");
row = sc.nextInt();
System.out.println("Enter number of
cols: ");
cols = sc.nextInt();
Random r = new Random();
for (int i = 0; i < row; ++i)
{
for (int j = 0;
j < cols; ++j) {
a[i][j] = r.nextInt(100) - 50;
}
}
System.out.println("Original Matrix
");
display(a);
tConverted(a);
System.out.println("\nAfter T
converted ");
display(a);
}
}
===============================================================================
SEE OUTPUT
![60 61e public static void tConvertedCint tOO) I 62 63 64 65 <terminated> Array2d [Java Application] /L Enter number of rows f](http://img.homeworklib.com/images/5dfaa964-570c-41ae-82a3-c2be487fc410.png?x-oss-process=image/resize,w_560)
Thanks, PLEASE COMMENT if there is any concern.
(20) 3. Develop a method convert that given a 2D array of integers t as the input argument return...
java code
Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.
Write a method that takes in a two-dimensional array of integers, do some calculation for each row in the two-dimensional array, and returns a one-dimensional array of sums for each row. Your code must work any array dimensions, including jagged arrays. The calculations are: • Sum of each row • Maximum value of each row • Minimum value of each row • Average of each row Here is an example an array passed and returns an array of sums for...
In JAVA: Write a method that reverses the array passed the argument and returns this array. Write a test program that prompts the user to enter ten numbers, invokes the method to reverse the numbers and display the numbers. Write a method that returns a new array by eliminating the duplicate values in the array using following method header: a. Public static int[] eliminateDuplicates(int list) b. Write a test program that reads in ten integers and invoke the method, the...
Java programming: I need to create a method that is given a 2D char array and a String that returns a part of the original 2D array. The input string will tell the method which rows from the input array need to be returned. For example, a 5x5 char array input along with a string "0 4" would return rows 1 and 5 of the input array. The String input will always be numbers divided by spaces and will not...
Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X – Y The signature of the function is: int f(int[ ] a) Examples if input array is return {1} 1 {1, 2} -1 {1,...
This is java, please follow my request and use netbeans.
Thank you.
A3 15. 2D Array Operations Write a program that creates a two-dimensional array initialized with test data. Use any primitive data type that you wish. The program should have the following methods: • getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array. .getAverage. This method should accept a two-dimensional array as its argument and return...
USING C++: Write a function that given a 2D dynamic array of integers, will return the number of elements whose absolute value is smaller than a given value x. The function should take as arguments (in this order): a pointer to the array (i.e., 2D dynamic array) the number of rows the number of columns the given value The function should return the number of elements smaller in absolute value than epsilon E.g. if A={{0.2, -0.1, 3.4},{4.4, 0, -2}} and...
a. Write a method that receives (a reference to an array of integers and returns the number of odd values in the array that are between 20 and 35 (inclusive) or greater than 65 (also b. Write a single Java expression in Java that corresponds to the following formula: 2 (y3 – 5) - VZ)10)
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...
We need to write a method that, given a key as an argument, returns the next in order key found in the binary search tree. If the key given as an argument is not found, the method should still return the next in order key. If the binary tree is empty or all the stored keys are smaller than the argument, then the return value should be empty. For example, using a collection of {10,13,52,67,68,83} stored in the binary search...