Solved

While Loop Simulation For Each Call of the Method Below, Write the Value

Question 2

Essay

While Loop Simulation
For each call of the method below, write the value that is returned:
public static int mystery(int i, int j) {
int k = 0;
while (i > j) {
i = i - j;
k = k + (i - 1);
}
return k;
}
Method Call Value Returned
mystery(2, 9) _______________________________
mystery(5, 1) _______________________________
mystery(38, 5) _______________________________
mystery(5, 5) _______________________________
mystery(40, 10) _______________________________

Correct Answer:

verifed

Verified

Related Questions