Write the definition of a method named printPowerOfTwoStars that receives a non-negative integer n and prints a string consisting of “2 to the n” asterisks.

LANGUAGE: JAVA

CHALLENGE:

Write the definition of a method named printPowerOfTwoStars that receives a non-negative integer n and prints a string consisting of “2 to the n” asterisks. So, if the method received 4 it would print 2 to the 4 asterisks, that is, 16 asterisks:
****************
and if it received 0 it would print 2 to the 0 (i.e. 1) asterisks:
*
The method must not use a loop of any kind (for, while, do-while) to accomplish its job.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,