While Loop Simulation
Category: Simulation
Author: Benson Limketkai
Book Chapter: 5.1
Problem: While Loop Simulation
For each call below to the following method, write the output that is printed, as it would appear on the console:
public static void mystery(int x, int y, int z) {
while (x >= y && x > z) {
x = x - z;
y--;
z++;
}
System.out.println(x + " " + y + " " + z);
}
1) mystery(31, 4, 15);
2) mystery(8, 4, 2);
3) mystery(0, 0, 7);
4) mystery(9, 1, 1);