desislava_topuzakova

5. Повтаряне на текст -> void

Feb 6th, 2022
1,323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package Methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class RepeatText_05 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String text = scanner.nextLine();
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.         //метод, който отпечатва текст n на брой пъти
  11.         printText(n, text);
  12.     }
  13.  
  14.     public static void printText (int n, String text) {
  15.         for (int time = 1; time <= n; time++) {
  16.             System.out.print(text);
  17.         }
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment