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 is entered. should also not be counted as an even or an odd number for this problem.
The input prompts should all be:
Enter a number 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 : 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:
Enter a number:
Enter a number:
Enter a number:
Enter a number:
Enter a number:
Enter a number:
Enter a number:
There were even numbers.
There were odd numbers.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
