Question: Create a single Java class with a main method and the four methods outlined below. The mainline should call each of these methods. (a) Write
Create a single Java class with a main method and the four methods outlined below. The mainline should call each of these methods.
(a)
Write a recursive function that reads a list of integer values, sentinel -1, and prints all multiples of 3. The signature of the function is:
void multipleThree(Scanner in){ }
(b)
Write a recursive function that takes an integer array as one of its arguments and computes the frequency of the number 0 in the array.
(c)
Write a recursive function that prints a given positive integer value as its binary equivalent. For example, if the value is 11 the output should be 1011.
(d)
The recursive function fibSequence() described in the book and in the lectures generates and prints the first n terms in the fibonacci sequence. Re-write this function so that it actually stores the terms in an array of size n, where n is the number of terms required, as it generates them. The signature of this function is:
void fibSequence(int i,int n, int f[]){ }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
