Solved

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

Question 6

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

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents