- Read the question carefully (twice).
- Break the task into the smallest steps.
- Sketch or write pseudocode before coding.
- Start small — test as you go.
- Check your solution with different cases.
Problem Description
Numbers can be even or odd:
- An even number is any number that can be divided by 2 with no remainder (for example: 2, 4, 10).
- An odd number is any number that has a remainder of 1 when divided by 2 (for example: 3, 7, 11).
Your task is to write a program that checks if a number is even or odd.
Learning Goals
By completing this problem, you should be able to:
- Use input and output in your program.
- Apply the modulus operator (
<strong>%</strong>) to test divisibility. - Use if / else statements to make decisions in your code.
- Test your program with different values to check accuracy.
Tasks
Task 1: Basic Even/Odd Check
- Write a program that:
- Asks the user to enter a number.
- Uses the modulus operator (
%) to check if the number is even or odd. - Prints either
"The number is even"or"The number is odd".
Task 2: Handle Zero
- Update your program so that if the user enters
0, the program prints:"0 is even."
Task 3: Handle Negative Numbers
- Update your program so that it works correctly even if the user enters negative numbers.
- Example:
-4→ Even-7→ Odd
Task 4: Test Cases
Run your program with these numbers and write down what your program prints:
0→ Even1→ Odd2→ Even15→ Odd-8→ Even-13→ Odd
Extension Challenge (Optional)
Add extra features to your program:
- After showing the result, ask the user if they want to check another number.
- If yes, run the program again.
- If no, print
"Goodbye!"and end the program.
✅ Success Criteria:
- You can explain the difference between even and odd numbers.
- Your program uses
%andif / elsecorrectly. - Your program works for positive, negative, and zero inputs.
- (Extension) Your program can run multiple times until the user decides to quit