Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Answer in Java with Javadocs with Comments for an upvote thank you Write a java program that has three static recursive methods and a
Please Answer in Java with Javadocs with Comments for an upvote thank you
Write a java program that has three static recursive methods and a main method. In your main method prompt for user input and display the results of each of your recursive methods as shown in the sample output below. a) Write a method that uses recursion to compute the value of a^n, where a and n are both integer arguments to the method. If n = 0, the method should return 1 as a^0 = 1. If n = 1, the method should return a as a^1 = a. If n is any other number ... that's for you to determine but remember, a^n = a x a^(n-1). b) Write a method that uses recursion to return the reverse of a String that is passed to the method as an argument. Hint: For base cases, consider a string that has 1 or fewer characters...how much work is there to reverse them? Otherwise a reversed string is the last letter of the original string plus the reverse of the rest. Try it out on paper first. c) Write a recursive method that determines the number of digits in an integer, n. Hint: If nStep 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