If/Else Simulation
Category: Simulation
Author: Helene Martin 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) {
int z = 0;
if (x >= y) {
x = x / 2;
z++;
}
if (x > z && y <= z) {
z++;
} else if (x > z) {
y = y - 5;
}
System.out.println(x + " " + y + " " + z);
}
1) ifElseMystery(4, 1);
2) ifElseMystery(-10, 100);
3) ifElseMystery(18, 4);
4) ifElseMystery(-12, 5);