Guest User

Untitled

a guest
Mar 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.93 KB | None | 0 0
  1. public class Main
  2. {
  3.     public static void main( String args[] )
  4.     {
  5.         int userE = 7;
  6.         int check = 1;
  7.  
  8.         System.out.print( "#Please Enter the stars you want  " );
  9.         userE = BIO.getInt();
  10.  
  11.         if (userE % 2 == 0)
  12.         {
  13.             System.out.println("Size" + " (" + userE + ") " + "invalid must be odd");
  14.             return;
  15.         }
  16.         if (userE <= 0)
  17.         {
  18.             System.out.println("Sides of square must be positive");
  19.             return;
  20.         }
  21.  
  22.         int line = 1;
  23.         double topLine = 0;
  24.         topLine = userE / 2;
  25.  
  26.         int keep = 1;
  27.         keep = userE;
  28.         int x = 1;
  29.        
  30.         //First Line Start
  31.  
  32.         while ( x < topLine+1 )
  33.         {
  34.             System.out.print( "." );
  35.             x++;
  36.             if( x == topLine+1 )
  37.             {
  38.                 System.out.print( "*" );
  39.             }
  40.         }
  41.        
  42.         x = 1;
  43.        
  44.         while ( x < topLine+1 )
  45.         {
  46.             System.out.print( "." );
  47.             x++;
  48.         }
  49.        
  50.         System.out.println("");
  51.        
  52.         //End first line
  53.  
  54.         //Start the center Section
  55.  
  56.         userE = userE / 2;
  57.  
  58.         while ( line <= userE )   // Top Half
  59.         {
  60.  
  61.             int s = 1;                      // Spaces before star
  62.             while ( s <= userE-line )
  63.             {
  64.                 System.out.print( "." );
  65.                 s = s + 1;
  66.             }
  67.  
  68.             int stars = line*2-1;           // width of stars segment
  69.  
  70.             int i = 1;                      //  display stars segment
  71.  
  72.             if ( i >= 1 || i <= userE - 1 )   // Printing the * then inside it
  73.             {
  74.                 System.out.print("*");
  75.                 while ( i <= stars )
  76.                 {
  77.                     System.out.print( "." );
  78.                     i = i + 1;
  79.                 }
  80.                 System.out.print("*");
  81.             }
  82.  
  83.             int k = 1;
  84.             while ( k <= userE-line )      // Fill gap
  85.             {
  86.                 System.out.print( "." );
  87.                 k = k + 1;
  88.             }
  89.  
  90.             System.out.println();           //  Newline
  91.  
  92.             line = line + 1;
  93.         }
  94.  
  95.         userE = keep;
  96.         userE = userE / 2;
  97.  
  98.         int store = 1;
  99.         store = userE;
  100.  
  101.         line = userE - 1;
  102.  
  103.         int lower = 1;
  104.  
  105.         while ( line >= lower )   // Bottom Half
  106.         {
  107.  
  108.             int k = 1;
  109.             while ( k <= userE-line )       // Fill Gap
  110.             {
  111.                 {
  112.                     System.out.print( "." );
  113.                     k = k + 1;
  114.                 }
  115.             }
  116.  
  117.             int stars = line*2-1;           // width of star segment
  118.  
  119.             int i = 1;                      //  display star segment
  120.  
  121.             if ( i >= 1 || i <= userE - 1 )   // Printing the * then inside it
  122.             {
  123.                 System.out.print("*");
  124.                 while ( i <= stars )
  125.                 {
  126.                     System.out.print( "." );
  127.                     i = i + 1;
  128.                 }
  129.                 System.out.print("*");
  130.             }
  131.  
  132.             int s = 1;                      // Spaces before star
  133.             while ( s <= userE-line )
  134.             {
  135.                 {
  136.                     System.out.print( "." );
  137.                     s = s + 1;
  138.                 }
  139.             }
  140.  
  141.             System.out.println();           //  Newline
  142.             line = line - 1;
  143.         }
  144.         // End Middle Section
  145.  
  146.         //Last Line Start
  147.         x = 1;
  148.         while ( x < topLine+1 )
  149.         {
  150.             System.out.print( "." );
  151.             x++;
  152.             if( x == topLine+1 )
  153.             {
  154.                 System.out.print( "*" );
  155.             }
  156.         }
  157.         x = 1;
  158.         while ( x < topLine+1 )
  159.         {
  160.             System.out.print( "." );
  161.             x++;
  162.         }
  163.         //End Last line
  164.  
  165.     }
  166. }
Add Comment
Please, Sign In to add comment