Question: will you be able to code this please? (java coding) Page 7 1 > of 2 CSC240 - Recursion Review Example: Given a non-negative int

will you be able to code this please? (java coding)
will you be able to code this please? (java coding) Page 7
1 > of 2 CSC240 - Recursion Review Example: Given a non-negative
int n, return the sum of its digits recursively. sumDigits (126) sumDigits
(49) sumDigits (2) - 2 + 9 + 13 For each of

Page 7 1 > of 2 CSC240 - Recursion Review Example: Given a non-negative int n, return the sum of its digits recursively. sumDigits (126) sumDigits (49) sumDigits (2) - 2 + 9 + 13 For each of the following exercises: a. Identify the base case b. Identify the recursive case c. Write a static java method that will perform the exercise. Call the method from main() using at least the given test cases. Display the results. Avoid creating any local variables in the methods. Exercises: 1. Given a non-negative int n, write an integer returning recursive method to count the occurrences of 7 as a digit. (Do not convert the number to a String). of 2 Exercises: 1. Given a non-negative int n, write an integer returning recursive method to count the occurrences of 7 as a digit. (Do not convert the number to a String). count? (717) count7 (7) count 7 (456) 2 1 0 2. Write an integer returning recursive method that accepts two positive integers and performs an integer divide by recursively subtracting the same number multiple times. int divide ( int num, int times.) divide ( 10, 0) + -999 (to represent "undefined") divide (5, 1) + 5 divide ( 18, 8) + 2 divide (155,15) 3. Write a boolean returning method to determine if a number is prime. Recursively determine if the any number less the number are divisible by the number. boolean isPrime(int num). - 10 isPrime( 919 ) true isprime 50) false Page > of lo divide (155, 15) 10 3. Write a boolean returning method to determine if a number is prime. Recursively determine if the any number less the number are divisible by the number. boolean isPrime( int num). isPrime( 919 ) isPrime( 50 ) false isprime ( 2 ) true true Use a helper method with a second parameter to count starting at 2. boolean primeHelper( int numtocheck, int count ...) isPrimeHelper ( 919, 2) + true a 4. Given a String, recursively build a new string where the vowels are duplicated. (Rather than modifying the existing String, build a new String one character at a time). String dupvowel ( String str ...) dupVowel ("hello") - dupvowel ("xxyy") dupVowel ("abc") "heel loo" "xxyy" "aabc" 5. Given an array of ints, recursively compute the number of times that a multiple of 8 appears in the array. int array8( int nums) ...] Use a helper function to incorporate an index to count through elements in the array. index is used to examine a specific element from the array, int arrayHelper( intnums, int index) ...) array ([8, 16, 311) array ( [25, 401) array([1, 2, 3, 4) - 2 - 1 +0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!