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
il63 [147K]
4 years ago
6

Write a method called makeStars. The method receives an int parameter that is guaranteed not to be negative. The method returns

a String whose length equals the parameter and contains no characters other than asterisks. Thus, makeStars(8) will return ******** (8 asterisks). The method must not use a loop of any kind (for, while, do-while) nor use any String methods other than concatenation. Instead, it gets the job done by examining its parameter, and if zero returns an empty string otherwise returns the concatenation of an asterisk with the string returned by an appropriately formulated recursive call to itself.
Computers and Technology
1 answer:
serious [3.7K]4 years ago
6 0

Answer:

// import the Scanner class

// to allow the program receive user input

import java.util.Scanner;

// The class Solution is defined

public class Solution{

   // main method to begin program execution

   public static void main(String[] args) {

       // scanner object scan is declared

       Scanner scan = new Scanner(System.in);

       // Prompt the user to enter a number

       System.out.println("Enter the number of stars you want: ");

       // user input is assigned to numOfStar

       int numOfStar = scan.nextInt();

       // call the makeStars method

       makeStars(numOfStar);

   }

   

   // makeStars method print stars using recursion

   // the method call itself till starNum == 0

   public static void makeStars(int starNum){

       if (starNum != 0){

           System.out.print("*");

           makeStars(starNum -1);

       }

   }

}

Explanation:

The code is well comment and solve the problem using recursion.

You might be interested in
Which feature of a website takes you to a different part of the website or a totally different website when you click on it?
lesantik [10]

A hyperlink is a feature that takes you to a different page when you click on it. That page could be part of the same website or a totally different website.

Let me know if you have any questions.

3 0
3 years ago
Read 2 more answers
How many searches should you complete when looking up information using online references?<br>​
antoniya [11.8K]
As many as it takes of course ;)
3 0
3 years ago
What is the easiest way to tame a dire wolf on Ark Survival Evolved?
Usimov [2.4K]

Answer:

Direwolves are large pack animals. ... Being carnivorous pack animals, Direwolves will likely attack on sight, so caution is advised. However, they do have the capability of being tamed, and are extremely loyal mounts once they are.

Explanation:

Taming and Feeding

You can tame a wolf by right clicking it with bones, and it could take anywhere from 1 to 6 bones. Black particles will appear each time you feed the wolf a bone, except for the last one, when you have tamed it, in which case there will be heart particles.

Happy to help...

7 0
3 years ago
What are the benefits of transferable skills check all the boxes that apply
Nonamiya [84]

Answer:

They allow easy cross-company transfers.

They help a person develop self-esteem.

They open up a variety of employment options.

Explanation:

7 0
4 years ago
Read 2 more answers
How does critical thinking relates to peer assessment?
Dovator [93]

Answer:

Peer review is a critical component of the life of the mind and an effective teaching strategy for nurturing students' critical thinking skills. ... peer review of writing is most effective when students have an opportunity to revise their writings prior to submitting a grade. Is it true that peer assessment helps students develop their critical thinking skills?

The students' perceptions of the peer evaluation activity were later elicited in interviews and a short written survey. The findings of the study indicate that peer evaluation activities did help in developing critical thinking skills, thus improving their academic writing performance.

Explanation:

8 0
2 years ago
Other questions:
  • Rewrite this method so that it avoids the use of a return statement:
    15·1 answer
  • What is the name of the feature that can be enabled on slower-speed WAN links to prevent a large data transfer from affecting th
    10·1 answer
  • Assume:
    14·1 answer
  • Elwin Osbourne, CIO at GFS, Inc., is studying employee use of GFS e-mail for non-business communications. He plans to use a 98%
    6·1 answer
  • Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
    10·1 answer
  • What service converts ip addresses into more recognizable alphanumeric names??
    8·1 answer
  • What is the final value for X ?<br><br> x= 1<br><br> x=13<br><br> x= x+3<br><br> x=0
    9·1 answer
  • Agile Software Development is based on Select one: a. Iterative Development b. Both Incremental and Iterative Development c. Inc
    11·1 answer
  • Anyone here play osu! ?
    11·2 answers
  • How important are operating system in our devices?​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!