Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // Please enter you student number
  2. // in this comment here:
  3.  
  4. class Main
  5. {
  6. public static void main( String args[] )
  7. {
  8. boolean process = false;
  9. while ( process )
  10. {
  11. System.out.print("#Enter size of box [<0 to exit]: ");
  12. int sq = BIOX.getInt();
  13. if ( sq < 0 )
  14. process = false;
  15. else if ( sq%2 == 0 )
  16. System.out.println( "Size must be odd: try again" );
  17. else
  18. printBox( sq );
  19. }
  20.  
  21. }
  22.  
  23. private static void printBox( int size )
  24. {
  25. for ( int row=1; row<=size; row++ )
  26. {
  27. for ( int col=1; col<=size; col++ )
  28. {
  29. if ( row == 1 || row == size )
  30. {
  31. System.out.print("*");
  32. } else {
  33. if ( col == 1 && col == size )
  34. {
  35. System.out.print( "*" );
  36. } else {
  37. if ( col%2 == 0 )
  38. System.out.print( " " );
  39. else
  40. System.out.print( "+" );
  41. }
  42. }
  43. }
  44. System.out.println();
  45. }
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement