Answer:
import java.io.*;
import java.util.*;
import java.lang.Math;
class GFG {
public static void PowerOfTwoStars(int n){
double a=Math.pow(2,n); //calculating the power..
for (int i=1;i<=a;i++)//looping to print the stars.
{
System.out.print("*");
}
}
public static void main (String[] args) {
Scanner star=new Scanner(System.in);//creating the scanner class object.
int n=star.nextInt();//taking input.
PowerOfTwoStars(n);//calling the function.
}
}
Input:-
3
Output:-
********
Step-by-step explanation:
In the method PowerOfTwoStars which contains one argument I have calculated the power that is 2 to the n.Then looping form 1 to power and printing the stars and for better explanation please refer the comments the code.