1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natta225 [31]
3 years ago
12

Write a method starString that accepts an integer parameter n and returns a string of stars (asterisks) 2n long (i.e., 2 to the

nth power).
Computers and Technology
1 answer:
lys-0071 [83]3 years ago
4 0

Answer:

public class Main

{

public static void main(String[] args) {

 System.out.println(starString(4));

}

public static String starString(int n){

    double p = Math.pow(2,n);

    String s = "";

    for(int i=0; i<p; i++)

        s += "*";

       

   return s;

}

}

Explanation:

Create a method named starString that takes an integer parameter, n

Get the 2 to the nth power using pow method and set it to the p

Create an empty string that will hold the asterisks

Create a for loop that will iterate p times. Inside the loop, concatenate an asterisk to the s

Return the s

Inside the main method, call the method with an integer parameter

You might be interested in
What does hdtv stand for
Gnesinka [82]
High Definition Television
8 0
4 years ago
Read 2 more answers
What is the purpose of the ISOWEEKNUM function? determines how many workdays are in a certain week determines how many workdays
ivanzaharov [21]

Answer:

It's D

Explanation:

5 0
3 years ago
Read 2 more answers
How does a computer work
ivann1987 [24]

Answer:

computer works on electricity

Explanation:

6 0
3 years ago
What is a conditional Statement that causes the program to change its course​
Deffense [45]

Answer:

In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.

Explanation:

3 0
3 years ago
While working on a forty-slide PowerPoint presentation, a user needs to quickly look over the six slides that have orange backgr
guapka [62]

Answer:

B

Explanation:

8 0
3 years ago
Other questions:
  • The act of engaging in crime through the use of a computer or similar type of device is called:
    8·1 answer
  • Which is a function of network media?
    11·2 answers
  • Databases can have various objects some of which are tables, queries, forms or views, and reports objects. Each of these has fie
    14·1 answer
  • Create a story that depicts the events leading up to a vehicle crash fatality, the crash itself, and the emotional aftermath on
    9·1 answer
  • What is blogging
    15·2 answers
  • Which screen should be open to customize or personalize a desktop background?
    15·2 answers
  • Could I use a prepaid card to buy a Brainly membership because I tried to get the trial with a low balance but more than like 5$
    11·1 answer
  • What is the mest gun in pixel gun 3d imma give you brainliest
    14·2 answers
  • I love my baby boy and can someone help me with this
    6·1 answer
  • The main part of your program has the following line of code.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!