Advertisement
YavorGrancharov

RectangleOfNxNStars

Feb 12th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RectangleOfNxNStars {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int n = Integer.parseInt(console.nextLine());
  7.         for (int i = 0; i < n; i++) {
  8.             System.out.println(repeatStr("*", n));
  9.         }
  10.     }
  11.     static String repeatStr(String str, int count) {
  12.         StringBuilder repeated = new StringBuilder();
  13.         for (int i = 0; i < count; i++) {
  14.             repeated.append(str);
  15.         }
  16.         return repeated.toString();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement