RomeScape

Programming => Java => Topic started by: Mazead on October 11, 2014, 06:17:46 pm



Title: Java diamond output in console
Post by: Mazead on October 11, 2014, 06:17:46 pm
Here is the code. (This is all mine, I am showing how I coded it.) I try to code very simple and straight forward. If you guys have any tips or comments please comment or PM me.

Quote
public class Diamond {
   
   public static void main(String[] args){
      
      int space = 5;
      int stars = 1;
      
      for(int height = 1; height <= 6; height++){
         
         
         for(int x = 1; x <= space; x++){
            System.out.print(" ");
            
         }
         
         space--;
         
      for(int x = 0; x < stars; x++){
         System.out.print("*");
      }
         
      stars += 2;
      System.out.println();
         
      }
   
      space = 1;
      stars = 9;
      
         for(int height = 1; height <= 6; height++){
         
         
      for(int spaces = 1; spaces <= space; spaces++){
         System.out.print(" ");
      }
      
      space++;
      
      for(int x = 0; x < stars; x++){
         System.out.print("*");
      }       
           
         stars -= 2;
           
      System.out.println();
         
      }
   }
   
   
}