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 is an example of a reputable website
Keith_Richards [23]
A reputable website would be one that you could research online and read about it's history , reviews etc .
4 0
3 years ago
Read 2 more answers
When you are making multiples of a brownie recipe, you cannot - without great difficulty - use a fraction of an egg. The calcula
Lera25 [3.4K]
The answer is one ☝️ question for the poll of a vote
5 0
2 years ago
In python:
Misha Larkins [42]

Answer:

Following are the code to this question:

list_val = input()#defining a integer variable for input value

test_grades = list(map(int, list_val.split()))#defining test_grades as a list

sum_extra = -999 #defining sum_extra that holds negative integer value

sum_extra = 0#defining sum_extra that holds value

for y in range(len(test_grades)):#defining a for loop to check range of list  

   if(test_grades[y] > 100):# defining if block that check list value is greater then 100

       sum_extra = sum_extra + (test_grades[y] - 100)#use sum_extra variable to hold extra value and add this value

print('Sum extra:', sum_extra)#print value

Output:

101 83 107 90

Sum extra: 8

Explanation:

In the above code a, "list_val" variable is declared, that uses an input method to input the values and declared a "test_grades" variable that uses a list method to add all values in the list.

In the next step, the "sum_extra" variable is declared, which holds some values and defines a for loop to check the range of the "test_grades", and define a if block, that checks list value is greater than 100. If the condition is true, it will remove the extra value, and add it into the sum_extera variable and add its value, and at the last use, print variable to print its value.

6 0
3 years ago
10 points if right...
aivan3 [116]

email because with chat it might wake up the kids and wbsite doesnt make sense. neither does blog so with email you can give personal messages and pictures.

7 0
3 years ago
Read 2 more answers
The engine type that is fired by gas or oil
salantis [7]
Internal combustion is the answer
8 0
3 years ago
Read 2 more answers
Other questions:
  • Q3** Write a query to create a new price list for books written by the same author. Allow the user to enter only the first 4 let
    15·1 answer
  • Wendy Patel is entering college and plans to take the necessary classes to obtain a degree in architecture. Research the program
    12·1 answer
  • There are two activities on your schedule, which are: 1) install server in lab 2) move server into the data center. however, the
    6·1 answer
  • 1. Bluetooth
    5·1 answer
  • Write down the pseudo code of a program that calculates the Body Mass Index (BMI) of
    9·1 answer
  • To combine concepts or ideas into a whole is called
    11·2 answers
  • LAB: Plant information (ArrayList) Given a base Plant class and a derived Flower class, complete main() to create an ArrayList c
    6·1 answer
  • How to square a number in java.
    15·1 answer
  • What are the differences between a cursor, insertion point and mouse pointer?​
    14·1 answer
  • In company a, there is a team that performs day-to-day it operations with a focus on security. they are responsible for a wide r
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!