While Loop Simulation
Category: Simulation
Author: Victoria Kirst
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 = 0; while (x < y && z < 4) { x = x * 2; y = y + 2; z++; } System.out.println(x + " " + y + " " + z); }
1) whileMystery(4, 3);
2) whileMystery(5, 7);
3) whileMystery(3, 18);
4) whileMystery(0, 4);