Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Module 9.3 | Challenge The power Method Overview In this challenge, you willcreate a class that contains a recursive method named power and a main
Module 9.3 | Challenge The power Method Overview In this challenge, you willcreate a class that contains a recursive method named power and a main method to execute it. The power method evaluates integer exponents with the exponent indicating the number of times the base number is used as a factor (for example 45 4 x 4x 4x4x 4, which results in 1024). The main method will allow a user to enter the values for base and exponent. Specifications PowerTesting.java The PowerTest class includes the power method and a main method power() Create a method power that receives two integer arguments and uses recursion to solve the integer exponent value o An example of a call to method power would be power (4, 5) with 1024 as the value returned by the methood When the base value is raised to exponent 1, the answer is base. (This is the base case of the recursion.) o o For the power method, assume that exponent is an integer greater than or equal to 1. o The recursion step should use this criteria baseValueexp baseValue x baseValueexp-1 main() . Prompt for and read input values from the user for the base and exponent. . Depending on the exponent value entered, report the correct information to the user: o Call the power method when the exponent is greater than zero and provide the answer o Output a statement with the answer '1' when the exponent entered is 0 (Do not call the power method.) Provide an error message for a negative exponent entry o After the first calculation and reported results, prompt the user to enter Y' to perform another calculation or 'N' to end the program. Additional Requirements .Follow the Basic Coding Standards. Include a comment section at the top of your program with your student ID, name, and title of the program
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