Advertisement
Guest User

RhombusOfStars

a guest
Feb 20th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by Jo on 2/18/2017.
  5.  */
  6. public class RhombOfStars {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         int rhombSize = Integer.parseInt(scanner.nextLine());
  10.  
  11.         for (int i = 1; i <= rhombSize; i++) {
  12.             System.out.print(draw(" ", rhombSize - i));
  13.             System.out.print(draw("*", 1));
  14.             System.out.print(draw(" *", i - 1));
  15.             System.out.println();
  16.         }
  17.  
  18.         for (int i = 1; i < rhombSize; i++) {
  19.             System.out.print(draw(" ", i));
  20.             System.out.print(draw("*", 1));
  21.             System.out.print(draw(" *", rhombSize - 1 - i));
  22.             System.out.println();
  23.         }
  24.  
  25.     }
  26.  
  27.     public static String draw(String str, int count) {
  28.         StringBuilder sb = new StringBuilder();
  29.         for (int i = 0; i < count; i++) {
  30.             sb.append(str);
  31.         }
  32.         return sb.toString();
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement