[Solved]Java Matrix Search Lab Write Class Randomly Load Matrix Integer Values Range 1 Upper Bound Q37023321
Java Matrix Search Lab
Write a class that will randomly load a matrix with integervalues that range from 1 to an upper bound, inclusive of the upperbound. Write methods to count the odds, evens, and primes. Writethese classes from the code provided. Please format answercorrectly.
Expanded directions:




Provided Code:
———–
//MatrixSearch Class
import java.util.*;
import java.io.*;
public class MatrixSearch
{
private int[][] mat;
/*
*pre – mat is null
*post – mat will be rows Xcols
*post – mat will contain integersthat are <= upper and >= 1
*/
public MatrixSearch( int rows, int cols, int upper )
{
}
/*
*pre – mat is not null
*post – count of odd numbers willbe returned
*post – no values in mat will havebeen changed
*/
public int countOdds( )
{
return 0;
}
/*
*pre – mat is not null
*post – count of even numbers willbe returned
*post – no values in mat will havebeen changed
*/
public int countEvens( )
{
return 0;
}
/*
*pre – mat is not null
*post – count of prime numbers willbe returned
*post – no values in mat will havebeen changed
*/
public int countPrimes( )
{
return 0;
}
/*
*pre – num has a value
*post – false is returned if num isdivisble by any number between 2 and itself
*post – true is returned if num isnot divisble by any number between 2 and itself
*/
private boolean isPrime( int num )
{
return false;
}
/*
*pre – mat is not null
*post – all values from mat areconcatenated to a string and returned
*/
public String toString()
{
return “”;
}
}
——————
//RunnerClass
import java.util.*;
import java.io.*;
public class MatrixSearchRunner
{
public static void main(String[] args) throws Exception
{
MatrixSearch ms = new MatrixSearch(40, 40, 15);
System.out.println( “Odd count = ” + ms.countOdds() );
//call count evens
}
}
Lab Goal This lab was designed to review basic class creation, method creation, matrices, nested loops, and searching Lab Description Write a class that will randomly load a matrix with integer values that range from 1 to an upper bound, inclusive of the upper bound. Write methods to count the odds, evens, and primes. Files Needed MatrixSearch.java MatrixSearchRunner.java Sample Data 20, 20, 25 10, 10, 50 7, 7, 100 Sample Output: 916 4 24 23 22 613 20 19 22 22 19 7 1 10 10 17 21 15 20 25 622 2 23 15 3 14 12 13 9 20 25 4 1 11 10 16 12 417 15 6 19 2216 23 8 19 6 19 15 142 21 15 24 25 16 15 14 1 18 6 6 13 22 15 24 23 159 21 11 12 4 10 23 19 1913 17 11 18 2 23 5 17 3 10 63 4 15 2 15 16 13 21 5 24 2 20 13 7 25 18 2 1 14 21 16 25 23 20 3 15 13 33 5 16 19 10 7 9 21 19 24 10 39 10 189 13 11 19 15 20 16 14 21 10 23 21 14 1 25 16 13 20 9 5 22 7 22 21 8 16 17 11 15 12 12 13 21 11 33 16 10 24 79 22 10 21 25 1 14 10 19 14 25 19 22 5 12 219 20 22 11 25 2 25 3 12 6413 20 22 15 11 11 3 16 Odd count 24 Even count 25 Prime count 11 Odd count-119 Even count106 Prime count 82 20 46 21 33 9 14 42 15 289 25 44 13 21 26 14 610 15 17 44 4 7321 17 14 6 21 21 49 35 46 23 47 17 29 42 45 5 24 45 38 29 24 1450 29 41 42 2 2 14 39 37 11 15 3 19 43 1 14 34 12 22 47 24 12 6 38 41 21 32 7 3820 34 32 16 37 39 15 4247 1 22 24 25 3 32 47 1 14 22 13 37 26 42 Odd count51 Even count 49 Prime count 32 65 10 73 42 69 23 2 28 86 79 82 54 46 52 11 63 88 20 69 28 93 5 84 89 22 41 53 83 2 49 61 4695 72 62 69 32 77 49 54 73 9 59 15 10 6568 58 Odd count 24 Even count 25 Prime count 11 Show transcribed image text Lab Goal This lab was designed to review basic class creation, method creation, matrices, nested loops, and searching Lab Description Write a class that will randomly load a matrix with integer values that range from 1 to an upper bound, inclusive of the upper bound. Write methods to count the odds, evens, and primes. Files Needed MatrixSearch.java MatrixSearchRunner.java Sample Data 20, 20, 25 10, 10, 50 7, 7, 100 Sample Output: 916 4 24 23 22 613 20 19 22 22 19 7 1 10 10 17 21 15 20 25 622 2 23 15 3 14 12 13 9 20 25 4 1 11 10 16 12 417 15 6 19 2216 23 8 19 6 19 15 142 21 15 24 25 16 15 14 1 18 6 6 13 22 15 24 23 159 21 11 12 4 10 23 19 1913 17 11 18 2 23 5 17 3 10 63 4 15 2 15 16 13 21 5 24 2 20 13 7 25 18 2 1 14 21 16 25 23 20 3 15 13 33 5 16 19 10 7 9 21 19 24 10 39 10 189 13 11 19 15 20 16 14 21 10 23 21 14 1 25 16 13 20 9 5 22 7 22 21 8 16 17 11 15 12 12 13 21 11 33 16 10 24 79 22 10 21 25 1 14 10 19 14 25 19 22 5 12 219 20 22 11 25 2 25 3 12 6413 20 22 15 11 11 3 16
Odd count 24 Even count 25 Prime count 11
Odd count-119 Even count106 Prime count 82 20 46 21 33 9 14 42 15 289 25 44 13 21 26 14 610 15 17 44 4 7321 17 14 6 21 21 49 35 46 23 47 17 29 42 45 5 24 45 38 29 24 1450 29 41 42 2 2 14 39 37 11 15 3 19 43 1 14 34 12 22 47 24 12 6 38 41 21 32 7 3820 34 32 16 37 39 15 4247 1 22 24 25 3 32 47 1 14 22 13 37 26 42 Odd count51 Even count 49 Prime count 32 65 10 73 42 69 23 2 28 86 79 82 54 46 52 11 63 88 20 69 28 93 5 84 89 22 41 53 83 2 49 61 4695 72 62 69 32 77 49 54 73 9 59 15 10 6568 58
Odd count 24 Even count 25 Prime count 11
Expert Answer
Answer to Java Matrix Search Lab Write a class that will randomly load a matrix with integer values that range from 1 to an upper … . . .
OR

