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
neonofarm [45]
3 years ago
15

Write a function in Java that implements the following logic: Given a string and an int n, return a string made of n repetitions

of the last n characters of the string. You may assume that n is between 0 and the length of the string, inclusive.
Computers and Technology
1 answer:
liubo4ka [24]3 years ago
8 0

Answer:

public class RepeatedString

{

public static void main(String[] args) {

 

 System.out.println(repeatString("apple", 3));

}

public static String repeatString(String str, int n) {

    String newString = str.substring(str.length()-n);

    System.out.println(newString);

    String ns = "";

    for(int i=0; i<n; i++) {

        ns += newString;

    }

    return ns;

}

}

Explanation:

- Create a function called repeatString that takes two parameter

- Get the last n characters of the string using substring function, and assign it to the newString variable

- Initialize an empty string to hold the repeated strings

- Initialize a for loop that iterates n times

- Inside the loop, add the repeated strings to the ns

- When the loop is done, return ns

- Inside the main, call the function

You might be interested in
30 POINTS FOR THE CORRECT ANSWER
Nonamiya [84]

In the case above, Ruben  should consider the printing option below:

  • Offset litho printing.
  • Digital Printing.
  • Screen printing.

<h3>What is the best printing type for books?</h3>

The use of digital printing is known to be the best in the case with Ruben. It is said to be much more economical in terms of shorter print runs.

Note that Digital printing do have fast turnaround time and as such it is better for books.

Therefore, In the case above, Ruben  should consider the printing option below:

  • Offset litho printing.
  • Digital Printing.
  • Screen printing.

Learn more about printing from

brainly.com/question/145385

#SPJ1

5 0
1 year ago
5.2
Ray Of Light [21]

Answer:

In order to reduce the risk of accidents on the roads.

Explanation:

The special equipment is used when  testing eyesight for a driver's license in order to reduce the risk of accidents on the roads. Good eyesight is very important for good and safe driving so to find out the eyesight of the driver, the license officer used special equipment in order to check driver's eyes. If the eyesight is good, the officer provide license to the person otherwise not so that no accidents happen on the road.

8 0
2 years ago
Carlos had 194 seeds and 11 flower pots he put the same number of seeds in each flower pot which is the best estimate for the nu
Anon25 [30]

Answer: in solution.

Explanation:

It is basically 194 divided by 11 since we are evenly grouping 194 seeds into 11 pots. This gives 17.636363…

This means that the best estimate is around that number.

6 0
2 years ago
Moving Images are called________.
Troyanec [42]

Answer:

films

Explanation:

- Pictures, comic strips, and animations is wrong because they are static images.

- Films are known as "moving pictures" and therefore are moving images. That makes film your correct answer.

- Hope this helps! If you would like a further explanation please let me know.

6 0
3 years ago
Which network type uses a coaxial cable to receive its signal?.
Tresset [83]
If you’re asking what I think your saying I know comcast does
6 0
2 years ago
Other questions:
  • Which is true about POP3 and IMAP for incoming email?
    6·1 answer
  • Hi <br> What exactly does this project want from me?thanks for riding
    5·1 answer
  • Select the correct answer.
    9·1 answer
  • PLEASE HELP ASAP i will mark brilliant
    12·2 answers
  • Describe how a cell’s content and format attributes are related.
    13·2 answers
  • With which type of test question should you leave yourself extra time to answer?
    14·2 answers
  • Which is the best choice to explain why a human resource manager is so
    5·1 answer
  • Consider the following declaration:
    11·1 answer
  • Which tool in Access will give you a detailed report showing the most accurate and complete picture of
    7·1 answer
  • _____ allows a function or operator to perform different tasks depending on the types of the arguments or operands. Group of ans
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!