hasAlternatingParity
Category: Arrays
Author: Stuart Reges
Book Chapter: 7.2
Problem: hasAlternatingParity
Write a static method hasAlternatingParity that returns whether or not an array of integers has alternating parity (true if it does, false otherwise). The parity of an integer is 0 for even numbers and 1 for odd numbers. To have alternating parity, a list would have to alternate between even and odd numbers, as in the following list: (3, 2, 19, 8, 43, 64, 1, 0, 3) If an array called "data" had the values above stored in it, then the following call: hasAlternatingParity(data) would return true. If instead the array stored the following values: (2, 13, 4, 1, 0, 9, 2, 7, 4, 12, 3, 2) then the call would return false because the list has two even numbers in a row (4 and 12). By definition, an empty list or a list of one element has alternating parity. You may assume that the values in the array are greater than or equal to 0. Write your solution to hasAlternatingParity below.