Question: The main objective of this lab is to implement Java programs and algorithms using recursion. Exercise 1 ( 1 0 marks ) Implement a recursive

The main objective of this lab is to implement Java programs and algorithms using recursion.
Exercise 1(10 marks)
Implement a recursive function to count the number of zeros in a number.
Note:
Example: 2030 has 2 zeros
If n has two or more digits
the number of zeros is the number of zeros in n?? with the last digit removed
plus an additional 1 if the last digit is zero
Examples:
number of zeros in 20030 is number of zeros in 2003 plus 1
number of zeros in 20031 is number of zeros in 2003 plus 0
numberOfZeros in the number N
K= number of digits in N
Decomposition:
numberOfZeros in the first K-1 digits
Last digit
Composition:
Add:
numberOfZeros in the first K -1digits
1 if the last digit is zero
Base case:
N has one digit (K=1)
The main objective of this lab is to implement

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 Programming Questions!