Counting Evens

Write a program CountingEvens that has the user enter a series of numbers. The program keeps track of how many even numbers were entered, and allows the user to keep entering values until a negative value (the sentinel) is entered. At that point the program tells the user how many even values were entered.

Even numbers are those that are evenly divisible by 2, ie. they have a remainder of 0 when divided by 2. The remainder, or modulo function in most programming languages is indicated by the operator %. To identify if an integer n is even, then:

if (n % 2 == 0)
{
    // this integer is even
}
else
{
    // the integer must be odd
}