Question: Translate into Java the following pseudo-code, expressed in plain English. Goal: We want to write a method that returns a mystery value (do not ask)

 Translate into Java the following pseudo-code, expressed in plain English. Goal:

Translate into Java the following pseudo-code, expressed in plain English. Goal: We want to write a method that returns a "mystery value" (do not ask) that it computed based on an integer value given as a parameter named "n". Variables declarations & initialization: Boolean variable named "flag", initialized to false. Int variable named "result", initialized to e. Steps for the code: While n is greater than e, do the following: Increment the variable "result" by 1. If the "flag" variable is false, set it to true and decrement the variable "n" by dividing it by 3. Else, set "flag" to false and increment "m" by multiplying it by 2. Return the value stored in the variable "result". mystery(0) - 0 mystery(2) - 1 mystery(3) - 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!