Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package methods;
- import java.util.Scanner;
- public class P07RepeatString {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- int n = Integer.parseInt(scanner.nextLine());
- String result = repeatString(input, n);
- System.out.println(result);
- }
- public static String repeatString(String textToRepeat, int n) {
- String output = "";
- for (int i = 0; i < n; i++) {
- output += textToRepeat; //abcabcabc
- }
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement