Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the number of stars in the middle of the rhombus: ");
- int numberOfStars = Integer.parseInt(sc.nextLine());
- //the for cycle for smaller to bigger part of the figure
- for(int row = 1; row<= numberOfStars;row++){
- for(int col = 1;col <= numberOfStars - row;col++){
- System.out.print(" ");
- }
- System.out.print("*");
- for(int col = 1; col<row;col++){
- System.out.print(" *");
- }
- System.out.println();
- }
- //the for cycle for bigger to the smaller part of the figure
- int bonus = 1;
- for(int row = numberOfStars - bonus; row >= 1;row--){
- for(int col = 1;col <= numberOfStars - row;col++){
- System.out.print(" ");
- }
- System.out.print("*");
- for(int col = 1; col<row;col++){
- System.out.print(" *");
- }
- System.out.println();
- bonus++;
- }
- }
- }
Add Comment
Please, Sign In to add comment