Write a recursive method that will compute the number of odd digits in a number.

What will be an ideal response?


```
public static long countOdd(long number){
long result;
if(number == 0)
// base case
result = 0;
else {
long digit = number % 10;
if(digit < 0)
digit = -1 * digit;
if(digit % 2 == 1)
result = countOdd(number/10) + 1;
else
result = countOdd(number/10);
}

return result;
}
```

This code is in Methods.java.

Computer Science & Information Technology

You might also like to view...

What section property indicates that the section is allowed to expand to accommodate fields that might expand?

A. Keep Together B. Repeat Section C. Special Effect D. Can Grow

Computer Science & Information Technology

A Word built-in cover page provides ________, which are placeholders to hold data categories

A) templates B) records C) fields D) boilerplates

Computer Science & Information Technology

A good password should have at least eight characters and use all lowercase letters

Indicate whether the statement is true or false.

Computer Science & Information Technology

Besides creating impact, what role does color play in package design?

What will be an ideal response?

Computer Science & Information Technology