Write a Java program that determines the number of odd, even, and zero digits of an input integer. For this program we consider 0 to be neither odd nor even. Print the results to the console with reasonable clarity in output. You must maintain the following constraints: • You must read the user input as a numeric value (not a string). • You must use the for loop as you solve this problem.(must use for loop) • You can use your choice branching constructs as necessary. • An input such as 0, 00, -1, -5, etc. are considered invalid input (but 01 is considered valid).
Write a Java program that determines the number of odd, even, and zero digits of an input integer. For
this program we consider 0 to be neither odd nor even. Print the results to the console with reasonable
clarity in output. You must maintain the following constraints:
• You must read the user input as a numeric value (not a string).
• You must use the for loop as you solve this problem.(must use for loop)
• You can use your choice branching constructs as necessary.
• An input such as 0, 00, -1, -5, etc. are considered invalid input (but 01 is considered valid).
• For your convenience, some sample input/output is below:
Enter a positive integer: 0
Invalid input.
Enter a positive integer: 0000
Invalid input.
Enter a positive integer: -4
Invalid input.
Enter a positive integer: 1234
There are in total 4 digit(s) in the number 1234.
Zero: 0
Even: 2
Odd: 2
Enter a positive integer: 105
There are in total 3 digit(s) in the number 105.
Zero: 1
Even: 0
Odd: 2
Enter a positive integer: 01
There are in total 1 digit(s) in the number 1.
Zero: 0
Even: 0
Odd: 1
Step by step
Solved in 3 steps with 6 images