If/Else Simulation
Category: Simulation
Author: Brett Wortzman
Book Chapter: 4.1
Problem: If/Else Simulation
Consider the following method: public static int ifElseMystery(int a, int b) { if (b > a) { int t = a; a = b; b = t; } if (a % 2 == 0) { return 2 * a + b; } else { return 2 * a - b; } } For each call below, write the value that is returned
1) ifElseMystery(4, 2);
2) ifElseMystery(1, 5);
3) ifElseMystery(2, 6);
4) ifElseMystery(3, 3);
5) ifElseMystery(5, 1);
6) ifElseMystery(2, 2);