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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started