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 (a > 0) { a = a - b; b++; System.out.print(a + " "); } System.out.println(b); }
1) mystery(7, 8);
2) mystery(11, 7);
3) mystery(25, 10);
4) mystery(-6, 10);
5) mystery(10, 3);