RomeScape
March 19, 2024, 03:09:17 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: My new email:
Pankers7@gmail.com
email me if u need anything Tongue
 
  Home   Forum   Help Search Arcade Staff List Login Register  

Java diamond output in console

Pages: [1]   Go Down
  Print  
Author Topic: Java diamond output in console  (Read 200 times)
0 Members and 1 Guest are viewing this topic.
Mazead
New-Member


Reputation +0/-0
Offline Offline

Posts: 10


View Profile
« 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();
         
      }
   }
   
   
}
Report Spam   Logged

Share on Facebook Share on Twitter



Pages: [1]   Go Up
  Print  
 
Jump to:  

Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum
Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy