Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main
- {
- public static void main( String args[] )
- {
- int userE = 7;
- int check = 1;
- System.out.print( "#Please Enter the stars you want " );
- userE = BIO.getInt();
- if (userE % 2 == 0)
- {
- System.out.println("Size" + " (" + userE + ") " + "invalid must be odd");
- return;
- }
- if (userE <= 0)
- {
- System.out.println("Sides of square must be positive");
- return;
- }
- int line = 1;
- double topLine = 0;
- topLine = userE / 2;
- int keep = 1;
- keep = userE;
- int x = 1;
- //First Line Start
- while ( x < topLine+1 )
- {
- System.out.print( "." );
- x++;
- if( x == topLine+1 )
- {
- System.out.print( "*" );
- }
- }
- x = 1;
- while ( x < topLine+1 )
- {
- System.out.print( "." );
- x++;
- }
- System.out.println("");
- //End first line
- //Start the center Section
- userE = userE / 2;
- while ( line <= userE ) // Top Half
- {
- int s = 1; // Spaces before star
- while ( s <= userE-line )
- {
- System.out.print( "." );
- s = s + 1;
- }
- int stars = line*2-1; // width of stars segment
- int i = 1; // display stars segment
- if ( i >= 1 || i <= userE - 1 ) // Printing the * then inside it
- {
- System.out.print("*");
- while ( i <= stars )
- {
- System.out.print( "." );
- i = i + 1;
- }
- System.out.print("*");
- }
- int k = 1;
- while ( k <= userE-line ) // Fill gap
- {
- System.out.print( "." );
- k = k + 1;
- }
- System.out.println(); // Newline
- line = line + 1;
- }
- userE = keep;
- userE = userE / 2;
- int store = 1;
- store = userE;
- line = userE - 1;
- int lower = 1;
- while ( line >= lower ) // Bottom Half
- {
- int k = 1;
- while ( k <= userE-line ) // Fill Gap
- {
- {
- System.out.print( "." );
- k = k + 1;
- }
- }
- int stars = line*2-1; // width of star segment
- int i = 1; // display star segment
- if ( i >= 1 || i <= userE - 1 ) // Printing the * then inside it
- {
- System.out.print("*");
- while ( i <= stars )
- {
- System.out.print( "." );
- i = i + 1;
- }
- System.out.print("*");
- }
- int s = 1; // Spaces before star
- while ( s <= userE-line )
- {
- {
- System.out.print( "." );
- s = s + 1;
- }
- }
- System.out.println(); // Newline
- line = line - 1;
- }
- // End Middle Section
- //Last Line Start
- x = 1;
- while ( x < topLine+1 )
- {
- System.out.print( "." );
- x++;
- if( x == topLine+1 )
- {
- System.out.print( "*" );
- }
- }
- x = 1;
- while ( x < topLine+1 )
- {
- System.out.print( "." );
- x++;
- }
- //End Last line
- }
- }
Add Comment
Please, Sign In to add comment