Assertions
Category: Assertions
Author: Brett Wortzman
Book Chapter: 5.5
Problem: Assertions
For each of the five points labeled by comments, identify each of the following assertions as being either ALWAYS true, NEVER true or SOMETIMES true / SOMETIMES false. public static int mystery(int x) { int y = 0; int z = 1; <span class="assertionpoint">// Point A if(x % 2 == 0) { x--; z++; <span class="assertionpoint">// Point B } while(y < x) { <span class="assertionpoint">// Point C z = z + 2; y = y + z; <span class="assertionpoint">// Point D } <span class="assertionpoint">// Point E return y; }
1) y < x
2) x % 2 == 0
3) z % 2 == 0