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
disa [49]
3 years ago
7

Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to

gether n times. For example, repeat("hello", 3) returns "hellohellohello", and repeat("ok", 1) returns "ok", and repeat("bye", 0) returns "". String concatenation is an expensive operation, so for an added challenge try to solve this problem while performing fewer than n concatenations.
Computers and Technology
1 answer:
svp [43]3 years ago
6 0

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

You might be interested in
A document repository is down when you attempt to access it. which isa principle is being violated?
Tju [1.3M]
When a document repository is down when you attempt to access it, the ISA principle Authentication is being violated. The authentication method is done during the log on phase and is performed by the ISA server which requests certificate. <span>The client then needs to send the appropriate client certificate to the server in order to be authenticated and to have access to the document.</span>
3 0
3 years ago
4) Wilkes continues to discuss the concept of time and how it relates to the type of photography he does. Why do you feel that t
lesya692 [45]

Wilkes photography style is solely focused on time lapse. His pictures from morning to night show the cycle of a day at a place in one image.

We cannot help you with the second problem , as we do not know what you learned in Unit 10.

3 0
3 years ago
Longer speeches should be separated into the paragraphs of:
Virty [35]

Answer:

b) About 100 words or 3-4 fines in the transcription tool.

Explanation:

Transcription tools are the software that helps in converting the audio or speeches into texts. Traditionally, the process of transcription was done manually. With teh advancement of technologies and software, transcription software is developed. They help in transcribing the audios and videos into texts. These are useful in many sectors of business, medical, and legal areas.

One of the rules of transcription involves the division of long speeches into paragraphs. It is advised to divide the paragraph into about 100 words or 3-4 lines.

7 0
3 years ago
Which type of business is best for Juanita to start? a corporation, because she needs a large investment to get started a sole p
Vedmedyk [2.9K]

A sole proprietorship, because she will work alone from home a franchise

7 0
3 years ago
Read 2 more answers
What does the following code print?double[] myList = {1, 5, 5, 5, 5, 1};double max = myList[0];int indexOfMax = 0;for (int i = 1
Liula [17]

Answer:

This code will print: 4

Explanation:

Following is the step-by-step explanation for the given code:

  • Given is the array of data type double named myList, it has entries, 1, 5, 5, 5,5, 1:

                    double[] myList = {1, 5, 5, 5, 5, 1};

  • Now the first element of the array (1) with index 0 will be stored in the variable max (data type double).

                 double max = myList[0];  

  • A variable indexOfMax having datatype int will be initiated as 0.

                 int indexOfMax = 0;

  • Now for loop will be used to find the maximum number of the array. The variable i will be put as index for each element to compare with first element. If the checked element is greater than or equal to the integer in max, it will be replaced. So at the end the variable max will have value 5 that will be at index i = 4.

                    for (int i = 1; i < myList.length; i++)

                            { if (myList[i] >= max)

                               { max = myList[i];

  • Now the variable i that is the index for max value will be stored in the variable indexOfMax (indexOfMax = 4).

                  indexOfMax = i; }}

  • At end the value stored in variable indexOfMax will be printed, so 4 will be printed as output.

              System.out.println(indexOfMax);

i hope it will help you!

7 0
3 years ago
Other questions:
  • In​ today's global​ environment, everything and everyone are digitally connected to everything and everyone else. The term used
    6·1 answer
  • The specific term for expediting the delivery of software by breaking a task into smaller increments is called
    12·1 answer
  • Which two keys on the keyboard allow an access user to move the insertion point to the next field to the right in datasheet view
    11·1 answer
  • WILL DO A BRIANLY! Use an algorithm to help the Python Turtle get to the finish line in 10 steps by using only the 3 commands be
    12·1 answer
  • A professional bureaucracy is a knowledge-based organization where goods and services depend on the expertise and knowledge of p
    7·1 answer
  • Which of the following statements about electronic cover letters is true?
    14·2 answers
  • In Access, it is possible to have _______________ fields, that is, fields that can contain more than one value.
    9·1 answer
  • WILL UPVOTE ALL
    10·1 answer
  • Project manager Kevin has to create a project team organizational chart. Which activity should he perform before creating this c
    9·1 answer
  • What are the 3 attributes of information?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!