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 a, int b) { while (b < a) { b = b + 3; a = a - b; System.out.print(a + " "); } System.out.println(b); }
1) mystery(20, 2);
2) mystery(16, -2);
3) mystery(10, 25);
4) mystery(3, -1);
5) mystery(15, 3);