Print stars in console like this using java ?
......*
.....*.*
... *...*
.. *.....*
. *.......*
...*.....*
... *...*
.....*.*
......*

dot = spaces

look to my code just i need to print border not filled shape

import java.util.Scanner;
public class Stars {

public static void main( String args[] )
{
Scanner input = new Scanner(System.in);
int number ;
System.out.print(" Enter Number of Middle Stars : ");
number = input.nextInt();

for (int i = 1; i <= number; i++)
{

for (int j = number; j >= i; j--)

{
System.out.print(" ");

if (j == i)
{
for (int d = 1; d <= i; d++)
{
System.out.print(" ");
System.out.print("*");
}
}
}
System.out.println("");
}

for (int i = number-1; i >= 1; i--)
{

for (int j = number; j >= i; j--)


{
System.out.print(" ");

if (j == i)
{
for (int d = 1; d <= i; d++)
{
System.out.print(" ");
System.out.print("*");
}
}
}
System.out.println("");
}
}

}
import java.util.Scanner;
public class Shape {

	public static void main(String[] args) {
		int num,i,j,k;
		Scanner input=new Scanner(System.in);
		System.out.print("Enter width :");
		num=input.nextInt();
		for(i=1;i<=num;i++)
		{
		for(j=num-i;j>=1;j--)
		{
		System.out.print(" ");
		}
		for(k=1;k<=i;k++)
		{
		if(k==1||k==i)
		System.out.print("*"+" ");
		else
		System.out.print(" "+" ");
		}
		System.out.println();
		}

		for(i=num-1;i>=1;i--)
		{
		for(j=num-i;j>=1;j--)
		{
		System.out.print(" ");
		}
		for(k=1;k<=i;k++)
		{
		if(k==1||k==i)
		System.out.print("*"+" ");
		else
		System.out.print(" "+" ");
		}
		System.out.println();
		}
		
	}

}
import java.util.Scanner;

public class Dia2{

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);

        System.out.print("Please Enter a Number: ");

        int num = input.nextInt();

        System.out.println();

        //this is the first shape which start from top to bottom

        for(int i = 1; i <= num ; ++i){//how many rows of stars do you want

            for (int x = i; x < num ; x++){// how many space to come before the begining of each row

                System.out.print(" ");
            }

            for(int j = 0; j < i; ++j){//how many stars per row


                System.out.print("*");//prints star on same line
                System.out.print(" ");//space between each star

            }

            System.out.println();//new row begins

        }

        //this is the second shape which starts fom bottom to top

        for(int a = num; a >= 0; a--){

            for(int b = a; b < num; b++){

                System.out.print(" ");

            }

            for(int y = 0; y < a; y++){

                System.out.print("*");
                System.out.print(" ");

            }

            System.out.println();

        }

    }


}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

start quote:

import java.util.Scanner;

public class Dia2{

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);

        System.out.print("Please Enter a Number: ");

        int num = input.nextInt();

        System.out.println();

        //this is the first shape which start from top to bottom

        for(int i = 1; i <= num ; ++i){//how many rows of stars do you want

            for (int x = i; x < num ; x++){// how many space to come before the begining of each row

                System.out.print(" ");
            }

            for(int j = 0; j < i; ++j){//how many stars per row


                System.out.print("*");//prints star on same line
                System.out.print(" ");//space between each star

            }

            System.out.println();//new row begins

        }

        //this is the second shape which starts fom bottom to top

        for(int a = num; a >= 0; a--){

            for(int b = a; b < num; b++){

                System.out.print(" ");

            }

            for(int y = 0; y < a; y++){

                System.out.print("*");
                System.out.print(" ");

            }

            System.out.println();

        }

    }


} 

end quote.

what exactly is the point of this post?

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.