Question: Consider the following method: For each of the following calls, indicate the value that is returned: a. mystery(3, 3) b. mystery(5, 3) c. mystery(2, 6)

Consider the following method:

public static int mystery (int x, int y) { while (x != 0 && y != 0) { if (x < y) { y -= x; } else { -= yi return x + y;

For each of the following calls, indicate the value that is returned:

a. mystery(3, 3)

b. mystery(5, 3)

c. mystery(2, 6)

d. mystery(12, 18)

e. mystery(30, 75)

public static int mystery (int x, int y) { while (x != 0 && y != 0) { if (x < y) { y -= x; } else { -= yi return x + y;

Step by Step Solution

3.57 Rating (178 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Output of mystery calls ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!