logo Practice-It logo

BJP4 Exercise 5.23: hasAnOddDigit

Language/Type: Java method basics mod return while loops
Author: Marty Stepp (on 2016/09/08)

Write a method named hasAnOddDigit that returns whether any digit of an integer is odd. Your method should return true if the number has at least one odd digit and false if none of its digits are odd. 0, 2, 4, 6, and 8 are even digits, and 1, 3, 5, 7, 9 are odd digits.

For example, here are some calls to your method and their expected results:

Call Value Returned
hasAnOddDigit(4822116) true
hasAnOddDigit(2448) false
hasAnOddDigit(-7004) true

You should not use a String to solve this problem.

Type your solution here:

This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.