Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by Jo on 2/18/2017.
- */
- public class RhombOfStars {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int rhombSize = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= rhombSize; i++) {
- System.out.print(draw(" ", rhombSize - i));
- System.out.print(draw("*", 1));
- System.out.print(draw(" *", i - 1));
- System.out.println();
- }
- for (int i = 1; i < rhombSize; i++) {
- System.out.print(draw(" ", i));
- System.out.print(draw("*", 1));
- System.out.print(draw(" *", rhombSize - 1 - i));
- System.out.println();
- }
- }
- public static String draw(String str, int count) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < count; i++) {
- sb.append(str);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement