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).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 

Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY