/* * diamonds.java * * Created on June 4, 2007, 11:39 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ /** * * @author Julie Baumler */ public class diamonds { /** Creates a new instance of diamonds */ public diamonds() { } /** * @param args the command line arguments */ public static void main(String[] args) { int max_width=9; // # of chars wide to make diamond int width=max_width % 2 == 0? max_width/2: max_width/2 +1; String stars="**********************************************"; String spaces=" "; for ( int i=1; i<(width*2); i++ ) { //System.out.print("spaces="); System.out.print( spaces.substring(0, (i < width ? width -i : i%width))); //System.out.print(" stars="); System.out.println(stars.substring(0,2*(i<=width? i : width-(i%width))-1 )); } } }