Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lab7RepeatString {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String text = scanner.nextLine();
- int counter = Integer.parseInt(scanner.nextLine());
- String newString = getRepeatString(text,counter);
- }
- private static String getRepeatString(String text, int counter) {
- for (int i = 0; i < counter ; i++) {
- System.out.print(text);
- }
- return text;
- }
- }
- /*Write a method that receives a string and a repeat count n (integer).
- The method should return a new string (the old one repeated n times).*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement