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
Ternary operators of computer<br><br>please explain. ​
Nitella [24]

Answer:

It's a compact way of doing an if-else statement.

General Format is

<<em>condition</em>> ? <if condition is true> : <else>;

Example:

I could rewrite:

  if(a==1) temp = 1;

  else     temp = 999;

as

  temp = (a==1) ? 1 : 999;

5 0
3 years ago
If an individual receives 1.8 mGy while standing 4 ft from a source of radiation for 2 minutes, which of the following option(s)
erastovalidia [21]

Answer:

The answer is letter B.

Explanation:

The option that will most effectively reduce her or his radiation exposure to that source is Standing 8 ft from the source for 2 minutes.

6 0
3 years ago
What is better in everybodys opinion. AMD or Intel?
Rama09 [41]

Answer:

Intel is more for work and such, while AMD is foucsed on gamers. I use AMD because I play many games, but it really depends on what you use your computer for.

Explanation:

4 0
2 years ago
Read 2 more answers
You may have come across websites that not only ask you for a username and password, but then ask you to answer pre-selected per
raketka [301]

Answer:

The questions are used to secure and identify you furthermore. Answering personal questions that only you can answer will deter someone from hacking into your account that easily.

Explanation:

5 0
2 years ago
The __________ certification program has added a number of concentrations that can demonstrate advanced knowledge beyond the bas
Sophie [7]

Answer:

CISSP

Explanation:

The CIDDP concentrations are an extension and development on the knowledge and credentials of the standard CISS certification that improves employability and career advancement

The CISSP concentrations includes

Information System Security Architecture Professional which can be known as ISSAP

Information System Security Engineering Professional which can be known as ISSEP

Information System Security Management Professional which can be known as ISSMP.

4 0
3 years ago
Other questions:
  • 10 facts about turbines
    11·2 answers
  • IPv6 can use a DHCPv6 server for the allocation of IPv6 addressing to hosts. Another IPv6 addressing option utilizes the IPv6 Ne
    10·1 answer
  • What happens as the key length increases in an encryption application?
    8·1 answer
  • Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output
    15·2 answers
  • An alteration threat violates information integrity. <br> a. True <br> b. False
    13·1 answer
  • How many passes will it take to find the five in this list?
    6·2 answers
  • Tiền tệ ra đời là kết quả
    7·2 answers
  • What is the minimum number of bits you would need to represent a number on a 0 to 10 scale
    15·1 answer
  • Difference between switch and switch lite
    10·1 answer
  • When the user types into a Textbox control, the text is stored in the control's __________ property.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!