Advertisement
skipter

Square of Stars N x N - Drawing Figures with Loops

Apr 13th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.         int numberOfStars = Integer.parseInt(input.nextLine());
  9.  
  10.         for (int i = 0; i < numberOfStars; i++) {
  11.             System.out.print("*");
  12.             for (int j = 1; j < numberOfStars ; j++) {
  13.                 System.out.print(" *");
  14.  
  15.             }
  16.             System.out.println();
  17.         }
  18.  
  19.     }
  20. //    public static String repeatStr(String str, int count) {
  21. //        StringBuilder stars = new StringBuilder();
  22. //
  23. //        for (int i = 0; i < count; i++) {
  24. //            stars.append(str);
  25. //        }
  26. //        return stars.toString();
  27. //   }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement