Simulation Write Output Statement Given Following Method Public Static Void Mystery Int X Q37055339

While Simulation

Write the output of each statement, given the followingmethod:

public static void mystery(int x) {

int y = 0;

while (x % 2 == 0){

x /= 2;

y++;

}

System.out.println(x + ” ” + y);

}

Statements: (This is where I am stuck, what are theoutputs?
mystery(9);

myster(6);

myster(12);

mystery(8);

myster(16);


Solution


to x 21- So it wll not enter bwile lep So this me thod will psn mysteujCo) K 6 9 -0 ente

uystay (3) 12 fal

Your Code 1- public class MyClass { public static void main (String args]) mystery (9); mystery (6); mystery (12); mystery (8Result... CPU Time: 8.11 sec(s), Memory: 29884 kiLobyte(s) 9 0 3 1 3 2 1 3 1 4

to

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.