logo CodeStepByStep logo

loopMysteryExam3

Language/Type: Java while return

For each call of the method below, write the output that is printed and the value that is returned:

public static int loopMysteryExam3(int x, int y) {
    int z = x + y;
    while (x > 0 && y > 0) {
        x = x - y;
        y--;
        System.out.print(x + " " + y + " ");
    }
    System.out.println(y);
    return z;
}
loopMysteryExam3(7, 5); output
loopMysteryExam3(7, 5); return
loopMysteryExam3(20, 4); output
loopMysteryExam3(20, 4); return
loopMysteryExam3(40, 10); output
loopMysteryExam3(40, 10); return

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.