Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following questions, determine the value returned as a result of the giv

ID: 3678212 • Letter: F

Question

For the following questions, determine the value returned as a result of the given method call.

public static int quest (int x, int y)

     (x < y)

          x;

    

          y + quest (x – 1, y + 1);

quest(4, 3);

public static in quest(int a)

(a <= 1)

     1;

     (a % 2 == 0){

          a – quest (a – 1);

    

          a + quest (a – 1);

public static int quest (int x, int y)

rem = x % y;

     (rem == 0)

          y;

    

    

          x = y;

          y = rem;

          return quest(x, y);

quest(330, 210);

Explanation / Answer

public static int quest (int x, int y){

    if(x < y)

         return x;

    else

        return y + quest (x-1, y + 1);
}

Value returned by quest(4, 3) : 6

public static int quest(int a){

       if(a <= 1)

           return 1;

       if(a % 2 == 0)

           return a -quest (a-1);

       else return a + quest (a-1);

   }

For which value we want output ??

public static int quest (int x, int y){

       int rem = x % y;

       if(rem == 0)

           return y;

       x = y;

       y = rem;

       return quest(x, y);
   }

Value of quest(330, 210) : 30

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote