Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

LinkedIN Community

Join our LinkedIN Community.

The sum of the odds and even numbers

Implement a program to read 10 positive numbers and independently calculate the sum of the odd and even numbers. If a negative number is entered, the program will display an error message and ask for the number again.

>>> %Run 
    Enter a number: 4
    Enter a number: 5
    Enter a number: 6
    Enter a number: 7
    Enter a number: 8
    Enter a number: 9
    Enter a number: 12
    Enter a number: -4
    Please enter only positive numbers
    Enter a number: 0
    Enter a number: 3
    Enter a number: 209
    Sum of the even numbers:  30
    Sum of the odd numbers:  233
>>> %Run
    Enter a number: -4
    Please enter only positive numbers
    Enter a number: -0
    Enter a number: 4
    Enter a number: 4
    Enter a number: 5
    Enter a number: 5
    Enter a number: 6
    Enter a number: 6
    Enter a number: 7
    Enter a number: 7
    Enter a number: 8
    Sum of the even numbers:  28
    Sum of the odd numbers:  24
>>> %Run 
    Enter a number: 2
    Enter a number: 4
    Enter a number: 6
    Enter a number: 8
    Enter a number: 0
    Enter a number: 16
    Enter a number: 18
    Enter a number: 20
    Enter a number: 36
    Enter a number: 90
    Sum of the even numbers:  200
    Sum of the odd numbers:  0
Insist that the students test their programs by giving them example
test executions.