Question: Write findPowers 0 ' s base case to output 4 to the power of 0 is 1 ? and return 1 if val is

Write findPowers 0's base case to output "4 to the power of 0 is 1? and return 1 if val is equal to 0.
Ex. If the input is 4, then the output is:
4 to the power of 0 is 1
4 to the power of 1 is 4
4 to the power of 2 is 16
4 to the power of 3 is 64
4 to the power of 4 is 256
import java.util.scanner;
public class CalculateResult {
public static int findPowers (int val){
int result;
V** your code goes here y
else {
result =4* findPowers (val -1);
System.out.println ("4 to the power of "+ val +"is "+ result);
}
return result;
}
public static void main(String[] angs){
Scanner senr = new Scanner(System. in);
 Write findPowers 0's base case to output "4 to the power

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!