Question: RecursiveExponent.java Write a recursive function that accepts two arguments into parameters x and y, and which returns the value of x raised to the power

RecursiveExponent.java

 RecursiveExponent.java Write a recursive function that accepts two arguments into parameters

x and y, and which returns the value of x raised to

the power y. Hint: exponentiation is equivalent to performing repetitions of a

Write a recursive function that accepts two arguments into parameters x and y, and which returns the value of x raised to the power y. Hint: exponentiation is equivalent to performing repetitions of a multiplication. For example, the base 4 raised to the 6th power = 4*4*4 * 4 * 4 * 4 = 4,096. The only file that you need to create is RecursiveExponent.java. Your main method should prompt the user to supply the base and exponent values (as integers), and then invoke the recursive method to calculate the value x raised to the power y. Sample outputs are shown in figures 1 and 2. You MUST write your own recursive function. You CANNOT use any of the static methods from the Math class. The main method of this programming task can be written in as few as 6 lines, and the recursive method, in as few as 6 lines. If you find yourself writing much more than that, then stop, and refer back to the lecture slides. Recall that a recursive method needs a base case, and when the base case is not met, then the recursive method reduces the problem to a smaller" one. What is the base: 4 What is the exponent: 6 4 raised to the power 6 is 4096 Figure 1: Sample invocation of RecursiveExponent.java What is the base: -3 What is the exponent: 5 -3 raised to the power 5 is -243 Figure 2: Sample invocation of RecursiveExponent.java, when the input base is a negative integer

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!