public class ProgramCorrectness { // Precondition: -10 <= x <= 7 public static int funcOne(int x) { // uses an assertion to enforce the specified precondition in the method assert (x >= -10 && x <= 7); return (3 * x * x * x) - (2 * x * x) + 5; } // Preconditions: -5 <= x <= -2, 6 <= y <= 13 public static int funcTwo(int x, int y) { return (3 * x * x * x) - (y * x * x) + 11; } // Postcondition: 0.25 <= return value <= 1.0 public static double funcThree(double x) { return 1.0 / x; } // Precondition: x is an integer public static int funcFour(int x) { int retVal; if (x % 2 == 0) { retVal = x * x - x; } else { retVal = (x + x) * (x + x); } assert(retVal % 2 == 0); return retVal; } // Precondition: x >= 1 public static void funcFive(int x) { int result = 1; int i = 0; do { i++; result = result * i; } while (i < x); } // QUESTION: Does this correct swap the locals a and b? Why or why not? public static void funcSix(int a, int b) { System.out.println("Before: a = " + a + " and b = " + b); if (a < b) { int r = a % b; a = b; b = r; } else { int r = b; b = a; a = r; } System.out.println("After: a = " + a + " and b = " + b); } public static void main(String[] args){ } }