View the step-by-step solution to:

# Notice that for odd numbers the sequence has a single I in the middle while for even values it has two Is in the middle . Test the method in mainly ....

class called Recursive and methods below as public static methods of that class.Requirement:Recursive class must nothave any fields.

Notice that for odd numbers the sequence has a single I in the middle while for even
values it has two Is in the middle .
Test the method in mainly . Hardcode all your test cases so that I can see how you tested.
the method .
Requirement : Your method must not use any global variables or fields . Only local
variables can be used in the method implementation .*
Add this new method to the Recursive class .

1
7
2
\5
\3
3
&quot; he method should return 4 in this case because 4 of these pairs match ( 2 - 2, 5 - 5, 8 - 8, and
1 - 1 ) . See more examples below .*
The method should throw an Illegal Argument Exception if either of the two parameters is
negative .
Test the method in maing . Hardcode all your test cases so that I can see how you tested
the method .
Requirements :&quot;
1 . Four method must not use any global variables or fields . Only local variables can
be used in the method implementation .*
You are not allowed to construct any objects other than Strings ( no array . List .`
Scanner , etc . ) and you may not use any loops to solve this problem : you must use
recursionl .*
Add this new method to the Recursive class
Recursive generate Patterns
Write a method generate Pattern ( int I ) that accepts an integer &quot; as a parameter and returns
a string containing a symmetric sequence of' i numbers as in example below . The method
should throw an Illegal Argument Exception a value less than I is passed as an argument .
Call
Returned String
generate Pattern ! ! ! ;\
generate Pattern ( 21 :
1
generate Pattern ( 3 ) ;
2 1 2)
generate Pattern ( 4) ;
2 1 1 2
generate Pattern ( 5) ;
3 2 1 2 3
generate Pattern (o) ;
3 2
\$ 1 1 2)
E.
GENERATE FatterNITI ;
4 3 2 1 2 3 4
GENERATE PATTERN (BY :`
\$ 2
1 1 2 3\
GENERATE Pattern ( S ) ;\
5 4 3 2 1 2 3 4 5
GENERATE Pattern ( 1 0 1 ;\
\5 4 3 2 1 1 2 3 4 5

the method. Add this new method to the Recursive class. Recursive Sum of Array Elements Write a recursive static method int recArraySumtint nums, int i} that
accepts an array of integers and an index i and returns the sum of all elements of that
array up to and including element with the index i. Test the method in mainO. Hardcode all your test cases. Requirement: Your method must not use any global variables or static ﬁelds. Only local
variables can be used in the method implementation. Add this new method to the Recursive class. Recursive Selection Sort Convert the regular iterative selection sort method into the recursive static one. In order
to achieve that. replace the outer loop in the solution by recursive calls and leave the second (inner) loop to be more or less as it is. Test your method in mainO. Make sure that your code works for arrays of size 1, 2, and 3
as well as a regular unsorted array. Do not use user input when testing the method — hard-
code all the test cases. Requirement: Your method must not use any global variables or ﬁelds. Only local
variables can be used in the method implementation. Add this new method to the Recursive class. Recursive countDigitMatchesO Write a recursive method countDigitMatches(int n1, int n2} that accepts two non-negative
integers as parameters and returns the number of digits that match between them. Two
digits match if they are equal and have the same position relative to the end of the
number (i.e. starting with the ones digit). In other words, the method should compare the
last digits of each number, the second-to-last digits of each number, the third-to-last digits of each number, and so forth, counting how many pairs match. For example, for the
call of countDigitZMatches (1072503 891, 62530341), the method would compare as
follows:

Assignment 4
Recursive product of E vens!&quot;
20 p
Recursive Sum of Array Elements
20 pts`
Recursive Selection Sort*
20 pts .
Recursive count Digit Matches !&quot;
20 pts .
Recursive generate Pattern! !
20 pts .
TOTAL : 100 pts.
General Requirements*
code in comments . I'msigned work automatically loses 5 pts .
` Describe the purpose of every variable
Explain the algorithm you are using for solution*
Add proper comments for all methods . Include [aparam , [return, and
a throws tags
Uncommented work loses up to 25% of the grade .
Archive the entire project using ZIP Or FLAR utility . Turn it in into the digital drop
box .
Create class called Recursive and write all methods below as public static methods of that*
class .
Requirement : Recursive class must not have any fields .
Recursive productofEvenso
Write a recursive method product ofEvens ( int. &quot; ) that returns the product of the
first &quot; even integers . See sample method calls below . The method must throw an*
I I I E g = ] Argument E x cept i on if the value of argument passed to it is less than or*
equal to 0 .
Product OF EVENs ( 1 1\
=
2
Product OF EVENs ( 2)
=
12
=
*
Product OF EVENS ( 3 )
12
* 4
6 :
= 48 )
product OF EVENS ( 4 )|
= 384\
12
\6
* { = 3 8 4 )
Requirement : Four method must not use any global variables or static fields . Only local
variables can be used in the method implementation .
Test the method in maing . Hardcode all your test cases so that I can see how you tested

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents