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
You have been tasked with training end users in security best practices and have observed a trend among users in which many are
quester [9]

Hi, A Tech-Savvy here.

Answer:

(C) Lengthen the time period between forced password changes.

7 0
3 years ago
__ are designed to be used with everyday objects, such as home appliances, gaming consoles, digital cameras, e-readers, digital
LenaWriter [7]

Answer:

Embedded Operating System

Explanation:

An embedded operating system is a specialized operating system dedicated to perform a unique task for a digital device other than your desktop or laptop. For example, we can find this operating system appears in a washing machine to enable user to control the operation of the washing machine. This type of operating system is designed to be more resource efficient. An embedded operating system can also found in cars, digital television, ATM machine, digital camera etc.

3 0
3 years ago
The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
Tanzania [10]

Answer:

highest of five numbers in the file

Explanation:

  • This code reads the file "some-file.txt" and saves the result in variable "somefile"
  • The runs a for loop for a count of 5.
  • In each loop it compares the current value of the file with the value of the variable result and if the result is true it updates the value of the variable result.
  • At the end of this code the variable result will contain the highest value in the file "some-file.txt" and print it.

3 0
3 years ago
If you have 5 bits, how high can you go in binary?
PilotLPTM [1.2K]
5 bit unsigned binary number is from 0 to (25-1) which is equal from minimum value 0 (i.e., 00000) to maximum value 31 (i.e., 11111).
4 0
3 years ago
What is payload?
Elina [12.6K]

Answer:

a block of data inside the paket

4 0
3 years ago
Other questions:
  • Which is the correct process for adding page numbers to a spreadsheet you will print? A. Click Page Break Preview. Type the page
    7·1 answer
  • The purpose of the trusted platform module is:
    15·2 answers
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the getEntry method?
    14·1 answer
  • In no less than two paragraphs, explain the risks and compliance requirements of moving data and services into the cloud.
    11·1 answer
  • Which of the following is an input device? (Select all that apply)
    13·1 answer
  • Which application is a digital version of a manual typewriter? A. Database B. Presentation C. Spreadsheet D. Word processor
    8·2 answers
  • the front desk of the Nocete's Hotel will comlute the total room sales (TRS) of Room 101.The room was occupied three times and t
    6·1 answer
  • Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and th
    12·1 answer
  • the ghost adventures team uses a variety of tools and technology in investigations. which one is described as an adjustable freq
    9·1 answer
  • What software can be used for remote operation of a sunsdr2 dx?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!