Advertisement
tchenkov

L06u06_RhombusOfStars

Feb 16th, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 15.02.2017 г..
  7.  */
  8. public class u06_RhombusOfStars {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int rhombusSideSize = Integer.parseInt(scan.nextLine());
  12.         String starSign = "* ";
  13.    
  14.         for (int i = 1; i <= rhombusSideSize; i++) {
  15.             rhombusLineOutput(rhombusSideSize, i, starSign);
  16.         }
  17.    
  18.         for (int i = rhombusSideSize - 1; i > 0 ; i--) {
  19.             rhombusLineOutput(rhombusSideSize, i, starSign);
  20.         }
  21.     }
  22.    
  23.     static void rhombusLineOutput(int rhombusSideSize, int signsCount, String fillSign){
  24.         int spacesCount = rhombusSideSize - signsCount;
  25.         String outputString = stringRepeater(" ", spacesCount);
  26.         outputString += stringRepeater(fillSign, signsCount);
  27.         System.out.println(outputString);
  28.     }
  29.    
  30.     static String stringRepeater (String stringToRepeat, int stringRepeatCount){
  31.         String outputString = "";
  32.         for (int i = 0; i < stringRepeatCount; i++) {
  33.             outputString += stringToRepeat;
  34.         }
  35.         return outputString;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement