Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Please enter you student number
- // in this comment here:
- class Main
- {
- public static void main( String args[] )
- {
- boolean process = false;
- while ( process )
- {
- System.out.print("#Enter size of box [<0 to exit]: ");
- int sq = BIOX.getInt();
- if ( sq < 0 )
- process = false;
- else if ( sq%2 == 0 )
- System.out.println( "Size must be odd: try again" );
- else
- printBox( sq );
- }
- }
- private static void printBox( int size )
- {
- for ( int row=1; row<=size; row++ )
- {
- for ( int col=1; col<=size; col++ )
- {
- if ( row == 1 || row == size )
- {
- System.out.print("*");
- } else {
- if ( col == 1 && col == size )
- {
- System.out.print( "*" );
- } else {
- if ( col%2 == 0 )
- System.out.print( " " );
- else
- System.out.print( "+" );
- }
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement