Question: 1. (20 points) Write an AllDigits Odd class that has a method called allDigits Odd that has an integer parameter and returns a boolean that

 1. (20 points) Write an AllDigits Odd class that has a

1. (20 points) Write an AllDigits Odd class that has a method called allDigits Odd that has an integer parameter and returns a boolean that specifies whether every digit of the integer is odd: o returns true if the integer consists entirely of odd digits (1,3,5,7,9) o returns false if any of its digits are even (0,2,4,6,8) Big Hint: You can loop through the number testing for even/odd (%) and then dividing by 10. You should complete the method with integers only. You should not convert the integer to a String. Method call examples: o allDigits Odd(135319) would return true o allDigits Odd(-9145293) would return false Your main method must: 1. Prompt the user for an integer. You can assume the user always types an integer and if the integer is not 0, it will not start with a 0. 2. Print whether or not the number has all odd digits in the using the format shown in the following example program execution: $ java AllDigitsodd Enter integer: 135319 allDigitsodd (135319): true $ java AllDigitsOdd Enter integer: -9145293 allDigitsodd(-9145293): false

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!