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]
4 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]4 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
Practice Home Survey
Ksivusya [100]

Answer:

Since this is a survey without preparation, you can move ahead as you like. However, still, you need to figure out the attributes. Here you need to register plugged in hours for each of your family members. And the same thing is abbreviated as screen time as well. You need to make a table with two columns, a family member's name, and the screen time or plugged in time. And you are not required to do anything else, as the survey is the method of collecting the data. And it does not deal with the analysis. The analysis will be done, when you will sit as an analyst. And in fact, you are making this impromptu survey for the family head, who is in charge of your family which can be your father or mother or your grand father or grand mother. And they can use these details for various findings, like how can they reduce cable TV cost per month, and so on. Your job is to collect the accurate data. And same thing, you need to repeat for all the survey that you are asked to conduct. Always remember, you need to know what data you need to collect through a survey. Plan for the survey only after finding the complete details about this. And even when asked to conduct as unprepared, this knowledge is essential.  

Explanation:

Please check the attachment.

5 0
4 years ago
What are two drawbacks of using netbook ? (Choose two)
nydimaria [60]

Answer:

D and C

Explanation:

I would say D and C because they don't have fast processors they normally only use Celerons. and normally they only have a 64GB internal SSD.

It's definitley not a because they are extremely portable and have amazing battery life

I don't think its B because they have small screens but you can also get them in bigger 14" variants which is normally the generic size.

5 0
3 years ago
As we move up a energy pyrimad the amount of a energy avaliable to each level of consumers
AleksandrR [38]

Explanation:

As it progresses high around an atmosphere, the amount of power through each tropic stage reduces. Little enough as 10% including its power is passed towards the next layer at every primary producers; the remainder is essentially wasted as heat by physiological activities.

8 0
3 years ago
It is safe to interchange oxygen and fuel gas hoses. A. False B. True
Marat540 [252]
False.
If you were to interchange one another it would be VERY life threatening.
6 0
4 years ago
Read 2 more answers
Code hs spell it out 7.2.6
fgiga [73]

what do you mean can you say it more clear?

4 0
3 years ago
Other questions:
  • Write a program that asks for a password and then verifies that it meets the stated criteria. • If the password meets the criter
    13·1 answer
  • Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): ""
    7·1 answer
  • Where is the brightness and contrast changed at?
    10·2 answers
  • what is it called when you are biying and selling products via electronic channels such as the internet​
    13·2 answers
  • Let's say that you're the sole IT person in your company, and your boss wants a way to block certain websites from employees. Wh
    6·2 answers
  • Software that protects confidentiality by screening outgoing documents to identify and block transmission of sensitive informati
    12·1 answer
  • Write python code that does the following.
    13·1 answer
  • Pick all the correct answers
    5·1 answer
  • Write a program that can perform three different activities:
    8·1 answer
  • How to find the next instance of text formatted in bold
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!