While Loop Simulation
Category: Simulation
Author: Jessica Miller and 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) { while (x > 0 && y > 0) { x = x - y; y--; System.out.print(x + " "); } System.out.println(y); }
1) whileMystery(7, 5);
2) whileMystery(20, 4);
3) whileMystery(40, 10);