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
goldenfox [79]
3 years ago
11

Write a method called makeLine. The method receives an int parameter that is guaranteed not to be negative and a character. The

method returns a String whose length equals the parameter and contains no characters other than the character passed. Thus, if the makeLine(5,':') will return ::::: (5 colons). 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 the specified character with the string returned by an appropriately formulated recursive call to itself.
Computers and Technology
1 answer:
Cloud [144]3 years ago
5 0

Answer:

public static String makeLine (int n, char c) {

   if (n ==0)

return "";

   else

       return (c + makeLine(n-1, c));

}

Explanation:

Create a method called makeLine that takes two parameters, int n and char c

If n is equal to 0, return an empty string

Otherwise, call the method with parameter n decreased by 1 after each call. Also, concatenate the given character after each call.

For example, for makeLine(3, '#'):

First round -> # + makeLine(2, '#')

Second round -> ## + makeLine(1, '#')

Third round -> ### + makeLine(0, '#') and stops because n is equal to 0 now. It will return "###".

You might be interested in
I want to message someone on Brainly but it wont let me. How many questions do I need to answer before I could message?
aliya0001 [1]
I’m not sure it’s about number of questions, I think it’s based off of rank. Good luck though! I’m happy to answer any questions you have!
6 0
4 years ago
Read 2 more answers
What is the Difference between raw_input and input?
erik [133]
The difference between raw_input and input is

when you're using raw input,  it returns a string and input and tries to run the input as phyton expression

hope this helps
3 0
3 years ago
Which term refers to a fact that naturally occurs in the universe?
MrMuchimi

Answer: a scientific law

Explanation:

8 0
3 years ago
Read 2 more answers
Name 3 examples of operating system software that are not Windows based.
anyanavicka [17]
Ubuntu, Linux, and Mint
4 0
4 years ago
Sona wants to start a business in India. Her friend suggest an idea to her is that to start business operations through an outsi
Alina [70]

Explanation:

to try and start her business

5 0
3 years ago
Other questions:
  • Terry came into work and turned on his computer. During the boot process, the computer shut down. When he tried again, the compu
    14·1 answer
  • What's the first step in being a wise consumer of media?
    10·2 answers
  • Jeremy is designing a website for a local pizza place. What is the appropriate resolution for him to set his images to?
    5·1 answer
  • How can you create the first row of the table as the header of the table
    15·2 answers
  • Normal or random variations that are considered part of operating the system at its current capability are ______: ​ a. systemic
    7·1 answer
  • Name two common methods for performing dependency injection.
    15·1 answer
  • Because collecting the adjustment data requires time, the adjusting entries are often a.estimated and recorded earlier than the
    8·2 answers
  • [5]Suppose a 1,600 kg car is traveling at 20.0 m/s. What average force is needed to stop the car in 4.0 s?
    8·2 answers
  • Decribe the advantages of using emails compared with physical faxing ?
    8·1 answer
  • Write a program which will -
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!