I have this assignment it prints out to a window but it all print out on 1 line
it should be in shape of a diamond but it looks like this:
**** *
import avi.*;
public class diamonds
{
public static void main(String[] args)
{
Window screen = new Window("diamond s.java","bold", "blue",18);
screen.showWind ow();
int max_width;
DialogBox inputMax_width= new DialogBox(scree n,"Enter an odd number, 1 or more!");
inputMax_width. showDialogBox() ;
max_width = inputMax_width. getInteger();
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++ )
{
screen.write( spaces.substrin g(0, (i < width ? width -i : i%width)));
screen.write(st ars.substring(0 ,2*(i<=width? i : width-(i%width))-1 ));
}
}
}
it should be in shape of a diamond but it looks like this:
**** *
import avi.*;
public class diamonds
{
public static void main(String[] args)
{
Window screen = new Window("diamond s.java","bold", "blue",18);
screen.showWind ow();
int max_width;
DialogBox inputMax_width= new DialogBox(scree n,"Enter an odd number, 1 or more!");
inputMax_width. showDialogBox() ;
max_width = inputMax_width. getInteger();
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++ )
{
screen.write( spaces.substrin g(0, (i < width ? width -i : i%width)));
screen.write(st ars.substring(0 ,2*(i<=width? i : width-(i%width))-1 ));
}
}
}
Comment