// Assertions - problem 1 // Assertion is a statement of *what you know* // A pre-condition is an assertion guaranteed to be // true before the code executes // i.e. the code can rely on it // A post-condition is an assertion guaranteed to be // true after the code executes // i.e. whatever uses your code can rely on it // pre : y >= 0 // post: returns x^y public static int pow(int x, int y) { int prod = 1; // Point A y>=0 while (y > 0) { // Point B y>0 if (y % 2 == 0) { // Point C y>0, y is even x *= x; y /= 2; // Point D y>0, y?? } else { // Point E y>0, y is odd prod *= x; y--; // Point F y>=0, y is even } // Point G y>=0, y?? } // Point H y==0, y is even return prod; } Assume the method is called only if the precondition is true. Fill in the table below with the words ALWAYS, NEVER or SOMETIMES. y == 0 y % 2 == 0 +---------------------+---------------------+ Point A | | | +---------------------+---------------------+ Point B | | | +---------------------+---------------------+ Point C | | | +---------------------+---------------------+ Point D | | | +---------------------+---------------------+ Point E | | | +---------------------+---------------------+ Point F | | | +---------------------+---------------------+ Point G | | | +---------------------+---------------------+ Point H | | | +---------------------+---------------------+