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
mojhsa [17]
3 years ago
10

Write the definition of a method named printPowerOfTwoStars that receives a non-negative integer n and prints a string consistin

g of "2 to the n" asterisks. So, if the method received 4 it would print 2 to the 4 asterisks, that is, 16 asterisks: ����**************** and if it received 0 it would print 2 to the 0 (i.e. 1) asterisks:
Computers and Technology
1 answer:
defon3 years ago
8 0

Answer:

import java.io.*;

import java.util.*;

import java.lang.Math;

class GFG {

   public static void PowerOfTwoStars(int n){

       double a=Math.pow(2,n); //calculating the power..

       for (int i=1;i<=a;i++)//looping to print the stars.

       {

           System.out.print("*");

       }

   }

public static void main (String[] args) {

    Scanner star=new Scanner(System.in);//creating the scanner class object.

    int n=star.nextInt();//taking input.

    PowerOfTwoStars(n);//calling the function.

}

}

Input:-

3

Output:-

********

Explanation:

In the method PowerOfTwoStars which contains one argument I have calculated the power that is 2 to the n.Then looping form 1 to power and printing the stars and for better explanation please refer the comments the code.

You might be interested in
Which is true of case-based reasoning (CBR)?
DaniilM [7]

Answer:

The correct option is Option C: It matches a new problem with a previously solved problem and its solution.

Explanation:

Case-based reasoning (CBR) is used when someone tries to solve new problems based on old problems that were similar. The person applying case-based reasoning would look for the solutions to these similar past problems and try to apply them to the new case. For example, a doctor who tries to treat a patient based on what was successful with a prior patient with a similar problem is applying case-based reasoning. In some instances, these problems are available in a database and ideally, that is how it is conceived, but it would depend on the field and the kind of problems. There is no universal global network dedicated to CBR as a whole (other than generic searches on the internet in general). One example of a specific CBR database is the European Nuclear Preparedness system called PREPARE.

4 0
3 years ago
Which document would be best created using Word online
topjm [15]
Resume       
6 0
3 years ago
Read 2 more answers
What is computer software
Butoxors [25]
A set of instructions and documents that tells a computer what to do or how to perform a task or it can mean all the software on a computer,
7 0
3 years ago
Read 2 more answers
according to the information-processing view of memory, the first stage in memory processing involves
ExtremeBDS [4]

Answer:The first stage of memory is encoding. In this stage, we process information in visual, acoustic, or semantic forms. This lays the groundwork for memory. The second stage is storing information so it can be recalled at a later point.

Explanation:sorry if its wrong

4 0
3 years ago
A special cloud called ______ is formed close to the ground when moisture condenses as air is cooled from below.
sveticcg [70]
D: Stratus. Stratus clouds<span> </span>form<span> when a layer of air is cooled from below to its dewpoint temperature and water vapor condenses into liquid droplets.</span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • In a social networking site your personal information is listed under your inbox. home. status. profile.
    11·1 answer
  • What is the car on the right?
    7·1 answer
  • Windows domain policy to disable windows 10 update
    7·1 answer
  • You can replace the parentheses on a function call with square brackets.
    11·1 answer
  • Swathi is using Base database software. Which filter function will enable her to filter data based on the field she clicks on?
    12·1 answer
  • How much time per day does the average U.S. youth spend watching television, playing video games, or using a computer?
    8·1 answer
  • Which is not a proper statement?
    14·2 answers
  • Which of the following is a type of input device?
    5·1 answer
  • How to get amount after a percentage increase in excel​
    8·2 answers
  • The RAM memory of a computer contains the volatile memory, which includes
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!