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
If you want to prioritize downloads of your mobile app instead of visits to your mobile site, you should: a) add a sitelink exte
scoray [572]

Answer:

create a Universal App campaign

3 0
3 years ago
6.
HACTEHA [7]
Question 6 west Germany  
3 0
3 years ago
Some hardware can be added to the computer without having to restart or power down the computer. After a short period of time th
Alja [10]

Answer:

The answer is "Option c"

Explanation:

Plug and Play is a general term that is used to define gadgets operating with a computer network while connected to it. This technology allows the hardware to use automatically by adding it, and other option can be described as follows:

  • In option a, This technology is used in monitoring the commercial vehicles system, which is why it's incorrect.
  • In option b, It is wrong because It is used in Microsoft Windows, which increases the physical security.
  • In option d, It describes the details about the hardware and switches to configure the device, that's why it is incorrect.
5 0
3 years ago
A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
Rzqust [24]

Answer:

C. The user is sent an e-mail appearing to be from the manufacturer, asking the user to confirm account password by clicking on a link in the e-mail and entering password on the resulting page.

Explanation:

Phishing attack is a cyber atttack in which user is sent an email which he thinks is useful. When the user open the email and does as instructed in the email his account gets locked. His personal information is haccked and then rannsom is demanded to release that information. The hacckers usually steal credit card information and bank details of the user which are misused.

7 0
4 years ago
1 pts Question 5 Which of the following calculations would evaluate to 12? (36) + 2/2, 3* ((6+2)/2), 3* 6+2/2, (306+ 2)/2​
julia-pushkina [17]

Answer:

Could you seperate them if they are different answers? I'm lost, sorry!

Explanation:

5 0
3 years ago
Other questions:
  • Which was the first media-sharing website that allowed users to submit their own work on the site?
    7·1 answer
  • What device can boost an analog signal? a digital signal?
    12·1 answer
  • Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
    5·1 answer
  • Need 9&amp;10. Thank you! Btw it's due today.
    11·1 answer
  • Assessing opportunity cost involves...
    6·1 answer
  • Write an algorithm that receives 500 numbers from the user and prints out the maximum of the numbers.
    9·1 answer
  • We use a cubic equation in which the variables and coefficients all take on values in the set of integers from 0 through p - 1 a
    8·1 answer
  • ACME Corp. is developing a software program that can run on mobile devices so that customers can interact with the firm, view pr
    13·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • If you said the bottom margin, you are talking about what?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!