Question: Try creating a program that counts the number of even numbers entered and the number of odd numbers entered. The program should continue until 0

Try creating a program that counts the number of even numbers entered and the number of odd numbers entered. The program should continue until 0 is entered. 0 should also not be counted as an even or an odd number for this problem.
The input prompts should all be:
Enter a number (0 to stop):
Note: There is a space and a newline after the colon.
After the loop has finished, print out the following:
There were {eNums} even numbers.
There were {oNums} odd numbers.
Replace eNums with how many even numbers there were and replace oNums with how many odd numbers there were.
Hint: Use variables to count the number of even numbers entered and the number of odd numbers entered.
Hint 2: How do we know if a number is even or odd? Try thinking of how modulo (%) can be used to accomplish this.
Below is a sample run as it would appear in the terminal:
Enter a number:
5
Enter a number:
11
Enter a number:
22
Enter a number:
14
Enter a number:
900
Enter a number:
34
Enter a number:
3
Enter a number:
0
There were 4 even numbers.
There were 3 odd numbers.

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 Programming Questions!