Question: The following Java method converts a positive decimal integer to base 8 (octal) and displays the result. Explain how the function works and trace it

The following Java method converts a positive decimal integer to base 8 (octal) and displays the result. Explain how the function works and trace it on the input n=100. static void displayOctal(int n){ if(n>0){ if(n/8>0){ displayOctal(n/8); } System.out.println(n%8); } } 7. Use what you learned in problem 6 above to create a recursive function called integerToString() that returns a String representation of an integer n expressed in base b. For instance the function call integerToString(100,8) would return the String 144, which is what was printed in problem 6. static String integerToString(int n, int b){ // your code starts here // your code ends here }

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!