Anybody Know how to Solve this Problem Thank you very much // ***** 1. This method has been coded as an example /** Fills the array with random numbers between 50 and 80 * The instance variable named intArray is the integer array to be * filled with values */ public void fillValues( ) { Random rand = new Random( ); for ( int row = 0; row < intArray.length; row++ ) { System.out.print( row + "\t" ); for ( int column = 0; j < intArray[row].length; column++ ) { intArray[row][column] = rand.nextInt( 31 ) + 50; animate( row, column, -1 ); // needed for visual feedback } System.out.println( ); } } // end of fillValues method // ***** 2. Student writes this method /** Prints array to the console, elements are separated by a space * The instance variable named intArray is the integer array to be * printed */ public void printArray( ) { // Note: To animate the algorithm, put this method call as the // last statement in your inner for loop // animate( row, column, -1 ); // where row is the index of the array's current row // and column is the index of the array's current column // Write your code here: } // end of printArray method // ***** 3. Student writes this method /** Sets all the elements in the specified row to the specified value * The instance variable named intArray is the integer array * @param value the value to assign to the element of the row * @param row the row in which to set the elements to value */ public void setValues( int value, int row ) { // Note: To animate the algorithm, put this method call as the // last statement in your for loop // animate( row, column, -1); // where row is the index of the array's current row // where column is the index of the array's current column // Write your code here: } // end of setValues method // ***** 4. Student writes this method /** Finds minimum value in the specified column * The instance variable named intArray is the integer array * @param column the column to search * @return the minimum value found in the column */ public int findMinimum( int column ) { // Note: To animate the algorithm, put this method call as the // last statement in your for loop // animate( row, column, minimum ); // where row is the index of the array's current row // column is the index of the array's current column // minimum is the variable storing the current minimum // Write your code here: return 0; // replace this line with your return statement } // end of findMinimumn method // ***** 5. Student writes this method /** Finds the number of times value is found in the array * The instance variable named intArray is the integer array * @param value the value to count * @return the number of times value was found */ public int countFound( int value ) { // Note: To animate the algorithm, put this method call as the // last statement in your inner for loop // animate( row, column, num ); // where row is the index of the array's current row // column is the index of the array's current column // num is the local variable storing the current frequency // count // Write your code here: return 0; // replace this line with your return statement } // end of countFound method
package Array;
import java.util.Random;
public class ArrayImp
{
int intArray[][];
ArrayImp()
{
intArray = new int[5][5];
}
// ***** 1. This method has been coded as an example
/** Fills the array with random numbers between 50 and 80
* The instance variable named intArray is the integer array to be
* filled with values
*/
public void fillValues( )
{
Random rand = new Random( );
for ( int row = 0; row < intArray.length; row++ )
for ( int column = 0; column < intArray[row].length; column++ )
intArray[row][column] = rand.nextInt(80 - 50) + 50;
} // end of fillValues method
// ***** 2. Student writes this method
/** Prints array to the console, elements are separated by a space
* The instance variable named intArray is the integer array to be
* printed
*/
public void printArray( )
{
for ( int row = 0; row < intArray.length; row++ )
{
for ( int column = 0; column < intArray[row].length; column++ )
{
System.out.print(intArray[row][column] + " ");
}
System.out.println( );
}
} // end of printArray method
// ***** 3. Student writes this method
/** Sets all the elements in the specified row to the specified value
* The instance variable named intArray is the integer array
* @param value the value to assign to the element of the row
* @param row the row in which to set the elements to value
*/
public void setValues( int value, int row )
{
for ( int column = 0; column < intArray[row].length; column++ )
intArray[row][column] = value;
} // end of setValues method
// ***** 4. Student writes this method
/** Finds minimum value in the specified column
* The instance variable named intArray is the integer array
* @param column the column to search
* @return the minimum value found in the column
*/
public int findMinimum( int column )
{
int min = intArray[0][0];
for(int row = 1; row < intArray.length; row++)
if(intArray[row][column] < min)
min = intArray[row][column];
return min;
} // end of findMinimumn method
// ***** 5. Student writes this method
/** Finds the number of times value is found in the array
* The instance variable named intArray is the integer array
* @param value the value to count
* @return the number of times value was found
*/
public int countFound( int value )
{
int counter = 0;
for ( int row = 0; row < intArray.length; row++ )
for ( int column = 0; column < intArray[row].length; column++ )
if(intArray[row][column] == value)
counter++;
return counter;
}// end of countFound method
public static void main(String []ss)
{
ArrayImp ai = new ArrayImp();
ai.fillValues();
ai.printArray();
System.out.println("\n Sets value 11 in row 3");
ai.setValues(11, 3);
ai.printArray();
System.out.println("\n Minimum value in column 3: " + ai.findMinimum(3));
System.out.println("\n number of times value 11 found: " +
ai.countFound(11));
}
}
Sample Output:
63 56 79 56 67
63 54 52 68 55
71 62 70 72 67
70 60 54 59 74
52 77 73 57 50
Sets value 11 in row 3
63 56 79 56 67
63 54 52 68 55
71 62 70 72 67
11 11 11 11 11
52 77 73 57 50
Minimum value in column 3: 11
number of times value 11 found: 5
Anybody Know how to Solve this Problem Thank you very much // ***** 1. This method...
java code please 14. Next we'll complete the setValues() method. Instead of giving you exact code I'll tell you what to do. Use other code as a guide. Start with a for loop with a start of int i = 0 Set the ending point of when i is less than the length of the arr array. Set the incrementation to increase i by 1 using the unary operator ++. Within the loop set the arr...
// I need help with the following questions. Please use java programming ECLIPSE language to solve the questions. YOU ONLY NEED TO DIRECTLY COPY IT IN YOUR ECLIPSE APPLICATION AND RUN IT. I NEED THOSE PART WHICH IS SAYS --> "TO BE COMPLETED" I NEED HELP WITH [GET*] AND [REPLACE ALL] AND [ADD INT DOUBLE] PLEASE. import java.util.ArrayList; public class CustomArrayList { //instance variables public int[] data; //data.length gives the capacity public int nItems; //nItems gives items currently in the...
I'm writing a program in java called Sokoban. I'm pretty far in, but there are a few methods that I have no idea where to go from where I am now. Method 1: /** * Moves a box on the board. * * Step 1: Use your checkDelta method to check that the move is valid. Recall that there are 2 * characters that can represent a box. Step 2: Use your togglePos method to correctly...
Exercise 1 Adjacency Matrix In this part, you will implement the data model to represent a graph. Implement the following classes Node.java: This class represents a vertex in the graph. It has only a single instance variable of type int which is set in the constructor. Implement hashCode() and equals(..) methods which are both based on the number instance variable Node - int number +Node(int number); +int getNumberO; +int hashCode() +boolean equals(Object o) +String toString0) Edge.java: This class represents a...
Using Java solve recursively without the use of loops or modifying the method signatures. /** * Given a sorted input array a, return a sorted array of size a.length + 1, * consisting of all elements of array a and integer i. * * @param a an array that is sorted in a non-descending order * @param i an integer * @return a sorted array of size a.length + 1, consisting of all elements of * array a and integer...
This is for Java. Create ONE method/function that will return an array containing the row and column of the largest integer i the 2D array. If the largest number is located on row 2, column 1, the method needs to return row 2 and column one. Do not use more than one method. Use the code below as the main. Please comment any changes. in java Given the main, create a method that RETURNS the largest number found in the...
Given the following construct a UML diagram for Java: Design a class named location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximum value and its indices in a two-dimensional array with row and column as int types and maxValue as double type. Write the following method that returns the location of the largest element in two-dimensional array: Public static Location locateLargest(double[][] a)...
Java 1. Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. 2. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in...
You will implement the following method public static int[] linearSearchExtended(int[][] numbers, int key) { // Implement this method return new int[] {}; } There is a utility method provided for you with the following signature. You may use this method to convert a list of integers into an array. public static int[] convertIntegers(List<Integer> integers) Provided code import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class MatrixSearch { // This method converts a list of integers to an array...
Can you tell me if this is right please import java.lang.reflect.AnnotatedArrayType; /** * The class <b>Point</b> is a simple helper class that stares a 2 dimentional element on a grid * * @author Guy-Vincent Jourdan, University of Ottawa */ public class Point { public int dot, row, col; // ADD YOUR INSTANCE VARIABLES HERE /** * Constructor * * @param x * the x coordinate * @param y * the y coordinate...