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
Dynamic disk storage provides the flexibility to logically organize disk space across one or more disk drives.
zhuklara [117]
<span>Dynamic disk storage provides the flexibility to logically organize disk space across one or more disk drives. 
a. True 
b. False</span>
3 0
3 years ago
Survey data can be collected with questionnaires. Which type of question has a limited number of preselected responses?
nadya68 [22]
The answer to your problem is B
8 0
3 years ago
What area contains the command used to customize the print options in microsoft excel?
Nezavi [6.7K]
The answer is Page Layout Ribbon.  The <span>area contains the command used to customize the print options in microsoft excel is Page Layout Ribbon.</span>
4 0
3 years ago
A ____ dynamic volume can only be created with three or more dynamic disks. raid 1 raid 5 raid 5i raid 23
aev [14]
The answer is Raid 5 and 23
8 0
3 years ago
An organization has its employees working from home. Which type of software most likely includes collaboration features to help
denis-greek [22]

Answer:

<h2>Google apps </h2>

Explanation:

What is Collaborative software?

Collaborative software is a software solution designed to help people work together while enhancing document sharing and a host of other functionalities.

Basically, collaborative software consists of a group of applications used by a team with a common goal

Google application is a perfect example of a collaborative software

It has web-based real-time collaboration: document, word processing, spreadsheet, presentation editing, and more of other features like meeting etc.

6 0
3 years ago
Other questions:
  • How to get 60 fps pubg​
    9·2 answers
  • How is abstraction used in a GPS system
    9·2 answers
  • Did this technological advancement take away or create jobs? Overall, what was the contribution of this technological advancemen
    12·1 answer
  • A mobile device user has entered her user ID and password to access an online account. The user immediately receives a text mess
    9·1 answer
  • 1D Array Assignment Outcome: Student will demonstrate the ability to use a one-dimensional array. Student will demonstrate the a
    5·1 answer
  • Who was the creator of the game Fnaf?
    11·2 answers
  • What are registers in ICT used for?
    5·1 answer
  • Write an algorithm and draw a flowchart for switching off a machine after it has made 500 glass bottles. use an appropriate cond
    10·1 answer
  • Individuals and IT professionals have a responsibility to be aware of security threats and the damage they might do.
    7·1 answer
  • What are organization tools?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!