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
Recommend how could you integrate positive aspects of digital literacy into your own
babymother [125]

Answer:

please give me brainlist and follow

Explanation:

7 Ways to Teach Digital Literacy

Emphasise the importance of critical thinking. ...

Use social media for learning and collaborating. ...

Provide guidance on how to avoid plagiarism. ...

Teach students to manage their online identity. ...

Help students manage digital distractions. ...

Provide authentic contexts for practice. ...

Guide students out of their comfort zone.

7 0
2 years ago
What is the Microsoft excel window where you work on. And it composed of three worksheet?​
antoniya [11.8K]

Answer:

work book

Explanation:

A work book is a book in MS excel which contains work sheet

4 0
2 years ago
If the fluid level in a battery is below the separators<br> should be added but never add
geniusboy [140]
Never add tap water to your battery. ... Battery electrolyte levels should be just below the bottom of the vent well, about ½ - ¾ inch above the tops of the separators. Never let the electrolyte level to drop below the top of the plates.
7 0
3 years ago
In high-tech fields, industry standards rarely change.<br> True <br> False
Sophie [7]

Answer: false

Explanation:

5 0
2 years ago
Explain what 10CLS program does and the write the output​
ludmilkaskok [199]
(CLS)


This text is being printed via the PRINT command."
On the next line, I'll use CLS, which will clear everything I just printed, so you won't even see the preceding text."
Also, you can't give CLS a line to PRINT; it won't actually do anything"
(CLS)
Finally, on line 80, I
3 0
2 years ago
Other questions:
  • Which of the following is important to do when downloading a game to your
    8·1 answer
  • Laura has identified the job she wants, the skills needed for the position, and the areas she needs to improve in order to get i
    10·1 answer
  • Match the part of motherboard to its function
    15·1 answer
  • With which type of media are you interacting when you read an online shopping website?
    7·1 answer
  • As an improvement of the ATX form factor over AT, shorter wires made it easier to shield them and made them capable of handling
    6·1 answer
  • Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the
    7·1 answer
  • For this exercise, you'll use the Rectangle class below (you can assume that the length and width are measured in feet).
    12·1 answer
  • A nonprofit organization uses a contact management database to track donations, amounts donated, and all correspondence and phon
    11·1 answer
  • Explain the characteristics of a first generation computer​
    8·1 answer
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!