Question
Scenario: You are writing a small app that will demonstrate the modularity of methods. Your application will prompt the user for a quantity of matrices
Scenario: You are writing a small app that will demonstrate the modularity of methods. Your application will prompt the user for a quantity of matrices to print. Each number that prints in each matrix will be a number between 0 and 9, inclusive. The quantity that the user enters will become the number of rows and columns in each matrix. For each matrix that is generated, you will also perform a frequency count of the numbers in that matrix (detailed below). Follow these general steps to get this program working: 1. Create a random number generating method called randNum( ). This method accepts two parameters, an int called lower and an int called upper. Your method will return back one single int randomly chosen between the range of lower and upper. Hint: Use the Math.random( ) method to generate the number to be returned. Examine Ch. 2 and 3 for its exact usage. Think about how to limit it to a range using this information. 2. Create a second method called matrixCreate( ). This method accepts two parameters: an int called rows and an int called cols. This method returns back a String. The method will build a matrix rows x cols large by concatenating the randomly chosen numbers into a String. It will call your method randNum() to generate each of these random numbers. It will return back the String. Hint: Since you are putting the matrix in a String variable, dont forget to include characters at the end of each row to make this matrix print properly later on! 3. Create a third method called frequencyCount( ). This method will accept a String parameter which contains the matrix returned by matrixCreate( ). This method returns back an String which contains a phrase that describes the frequency of numbers in the Matrix. Your method will process the matrix String parameter, and will count the frequency of numbers in these ranges: 1 3; 4 6; 7 9; The String the method returns will describe this frequency as seen in the example output below. 4. Finally, in your main( ) method, prompt the user to enter the number of matrices they wish to print and process. Your code will loop that number of times, calling the methods above in order to produce the output as seen below.
Example Run and Output:
Number of Matrixes?: 5
7 2 3 3 9
6 9 7 8 2
0 7 8 4 5
0 1 3 8 0
2 5 5 9 8
Count 1 - 3: 7
Count 4 - 6: 5
Count 7 - 9: 10
=========================
8 0 4 8
8 6 9 4
5 9 8 9
6 7 3 4
Count 1 - 3: 1
Count 4 - 6: 6
Count 7 - 9: 8
=========================
3 4 2
9 7 9
3 0 6
Count 1 - 3: 3
Count 4 - 6: 2
Count 7 - 9: 3
=========================
7 5
1 3
Count 1 - 3: 2
Count 4 - 6: 1
Count 7 - 9: 1
=========================
0
Count 1 - 3: 0
Count 4 - 6: 0
Count 7 - 9: 0
=========================
Second Example run and Output:========================================
Number of Matrixes?:
10
5 7 6 8 2 5 8 2 1 6
4 2 7 1 1 3 4 4 1 4
5 3 3 2 8 1 4 8 2 8
9 5 0 5 7 9 7 6 8 4
8 1 2 5 7 2 4 2 8 9
4 0 2 0 5 7 8 5 4 8
1 7 4 4 6 4 2 5 0 7
7 5 0 0 8 5 8 1 7 7
6 5 9 5 7 4 6 3 3 6
2 2 5 8 4 7 6 2 5 9
Count 1 - 3: 26
Count 4 - 6: 37
Count 7 - 9: 31
=========================
8 1 4 3 3 9 7 5 9
0 6 8 5 0 9 5 8 7
8 8 7 8 8 0 5 7 5
0 3 4 8 1 1 1 6 3
2 1 8 1 7 3 7 3 9
1 5 3 5 4 9 8 0 3
3 5 1 0 7 6 6 6 8
4 0 7 0 2 6 4 9 7
6 8 7 1 7 6 0 8 0
Count 1 - 3: 20
Count 4 - 6: 21
Count 7 - 9: 30
=========================
9 8 3 4 0 3 9 0
8 9 5 4 2 1 7 7
5 9 3 6 8 6 8 7
4 8 4 5 3 6 3 3
5 2 4 6 3 5 5 0
9 9 5 6 9 2 6 3
2 7 8 1 6 7 5 2
8 5 2 8 9 7 0 2
Count 1 - 3: 17
Count 4 - 6: 21
Count 7 - 9: 22
=========================
1 3 1 5 9 6 4
9 4 4 3 0 0 4
9 3 4 0 7 8 9
3 1 5 5 8 0 4
9 6 3 0 7 2 0
4 0 0 4 9 0 8
4 4 5 5 3 6 4
Count 1 - 3: 10
Count 4 - 6: 19
Count 7 - 9: 11
=========================
2 3 0 0 9 7
6 9 1 4 9 3
7 1 5 0 9 6
8 9 5 6 5 1
9 7 7 7 9 4
4 2 6 5 8 4
Count 1 - 3: 7
Count 4 - 6: 12
Count 7 - 9: 14
=========================
7 7 4 2 8
2 0 1 4 4
3 5 5 1 7
1 4 0 7 9
5 9 6 0 3
Count 1 - 3: 7
Count 4 - 6: 8
Count 7 - 9: 7
=========================
2 1 5 4
6 1 8 6
4 4 8 6
6 9 4 9
Count 1 - 3: 3
Count 4 - 6: 9
Count 7 - 9: 4
=========================
6 6 8
6 3 8
9 8 0
Count 1 - 3: 1
Count 4 - 6: 3
Count 7 - 9: 4
=========================
3 9
9 4
Count 1 - 3: 1
Count 4 - 6: 1
Count 7 - 9: 2
=========================
5
Count 1 - 3: 0
Count 4 - 6: 1
Count 7 - 9: 0
=========================
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started