Advertisement
veronikaaa86

RhombusOfStars

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