While Loop Simulation
Category: Simulation
Author: Marty Stepp
Book Chapter: 5.1
Problem: While Loop 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 whileMystery(int x, int y, int z) {
while (x < z || y < z) {
x = x + y;
y = y * 2;
System.out.print(x + " " + y + " ");
}
System.out.println();
}
1) whileMystery(0, 5, 10);
2) whileMystery(4, 2, 12);
3) whileMystery(10, 1, 14);