If/Else Simulation
Category: Simulation
Author: Jessica Miller and Marty Stepp
Book Chapter: 4.1
Problem: If/Else Simulation
For each call below to the following method, write the output that is produced, as it would appear on the console:
public static void ifElseMystery(int x, int y) {
if (x == y) {
x = x + 11;
} else if (x > 2 * y) {
x = 0;
}
if (x == 0 || y > x) {
x = x + 2;
y = y + 2;
}
System.out.println(x + " " + y);
}
1) ifElseMystery(5, 5);
2) ifElseMystery(18, 4);
3) ifElseMystery(3, 6);