Given the following: public int mystery3(int x , int y) { if(x < 0) return-myste
ID: 3608643 • Letter: G
Question
Given the following: public int mystery3(int x , int y) { if(x < 0) return-mystery3(-x,y); else if(y < 0) return-mystery3(x,-y); else if(x == 0 && y ==0) return 0; else return 100 *mystery3(x/10, y/10) + 10 * (x % 10) + y % 10; } What is returned by the method call: a) mystery3(5, 7)__________ b) mystery3(12, 9)__________ c) mystery3(-7, 4)_________ d) mystery3(13, 72)________ e) mystery3(-23, -48)_________ f) mystery3(128, 343)_________ Given the following: public int mystery3(int x , int y) { if(x < 0) return-mystery3(-x,y); else if(y < 0) return-mystery3(x,-y); else if(x == 0 && y ==0) return 0; else return 100 *mystery3(x/10, y/10) + 10 * (x % 10) + y % 10; } What is returned by the method call: a) mystery3(5, 7)__________ b) mystery3(12, 9)__________ c) mystery3(-7, 4)_________ d) mystery3(13, 72)________ e) mystery3(-23, -48)_________ f) mystery3(128, 343)_________Explanation / Answer
[a] 57 [b] 1029 [c] -74 [d] 1732 [e] 2438 [e] 132483 //here is trace of each call callingmystery3(5,7) none of the case, socompute 100 * mystery3(x/10, y/10) + 10 * (x % 10)+ y%10 calling mystery3(0,0) x==0 && y==0, so return 0 return 0 return 57 [a] 57 callingmystery3(12,9) none of the case, socompute 100 * mystery3(x/10, y/10) + 10 * (x % 10)+ y%10 calling mystery3(1,0) none of the case, so compute 100 * mystery3(x/10, y/10) + 10 * (x %10)+ y%10 calling mystery3(0,0) x==0 && y==0, so return 0 return 0 return 10 return 1029 [b] 1029 callingmystery3(-7,4) xRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.