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]
2 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]2 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
How does 5G technology enhance the Internet of Things (ioT) ?
Naddik [55]

Answer:

Internet of Things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster.

Explanation:

Internet of Things are basically any everyday item that has software that connects to the internet, in which that item sends or even receives data from it connecting to different servers using an internet service.

5G is a 5th generation technology that also connects to servers through an internet service. This 5G technology allows the items to receive information faster, which overall approves the internet service. One of the proud examples of 5G technology is our modern-day phones/appliances. 5G technology allows you to connect to an internet service and send information or receive information faster than 4G technology.

For your answer, since "internet of things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster."

Hope this helps.

4 0
1 year ago
Basil was reading about a new attack that forces the system to abandon a higher cryptographic security mode of operation and ins
Murljashka [212]

Since Basil was reading about a new attack that forces the system to abandon a higher cryptographic security mode of operation and the kind of attack is known to be Downgrade attack.

<h3>What is downgrade security attack?</h3>

A downgrade attack is known  to be a kind of of cyber attack that is made up of the fact that an attacker is known to often forces a network channel to make a switch to a kind of an unprotected or one that is said to be less secure data transmission standard.

Note also that the  Downgrading of a given protocol version is said to be a key element of  a type of a  man-in-the-middle attacks, and it is known to be one that is often used to take or hijack encrypted traffic.

Hence, Since Basil was reading about a new attack that forces the system to abandon a higher cryptographic security mode of operation and the kind of attack is known to be Downgrade attack

Learn more about Downgrade attack from

brainly.com/question/24304791

#SPJ1

3 0
1 year ago
Someone, please answer this.
Sav [38]

Answer: A loop will continue running until the defined condition returns false . ... You can type js for , js while or js do while to get more info on any of these. ... initialization - Run before the first execution on the loop. ... But it can be used to decrement a counter too. statement - Code to be repeated in the loop.

Explanation:

7 0
2 years ago
Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
katovenus [111]

Answer:

He can use following computer program to make the class room more interesting and effective:-

  • 1. <u>Reference software</u> : This software help students to access the atlases and dictionaries.Teacher can include this software in research projects .

  • 2. <u>Educational Games</u>: This types of software is very effective for younger children because it motivates them to learn.This software companies have combined gaming and education into one .

  • 3. <u>Graphical software</u> : Student can use this software to create and changes images available on the internet itselfs .
4 0
2 years ago
Read 2 more answers
Using refracted laser light to store data on a photoreceptive substrate is essentially how ___ storage works. Theoretically this
Alina [70]

Answer:

I try to search the answer but I couldn't find it

4 0
3 years ago
Other questions:
  • You need to put cabling for connecting two new computers in a room, which did not have any network infrastructure. Because of th
    9·2 answers
  • A way to have cells in your spreadsheet change formats based on the value of the cells is called ________.
    8·1 answer
  • During the past decade ocean levels have been rising faster than in the past, an average of approximately 3.1 millimeters per ye
    14·1 answer
  • Investments in data networks, ip addresses, routers, and switches are ________ because of their impact on productivity, security
    14·1 answer
  • What is the name for a hardcoded value entered into a formula ?
    8·2 answers
  • A look to different section of the same page is known as_____.
    7·1 answer
  • Write a Java program called Decision that includes a while loop to prompt the user to enter 5 marks using the
    12·1 answer
  • Excerpt from "How Prepared Are Students for College Level Reading? Applying a Lexile-Based Approach."
    6·1 answer
  • Give me facts on john john son
    7·1 answer
  • Difine the term pigment​
    14·3 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!