fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13.  
  14. int width=5,height=6,wallThick=2;
  15. if (width <= 0 || height <= 0 || wallThick <= 0)
  16. {
  17. System.out.println("Invalid value! Please enter positive integer.");
  18. }else {
  19.  
  20. int holeStartRow = wallThick + 1;
  21. int holeStartCol = wallThick + 1;
  22.  
  23. int holeEndRow = height - wallThick;
  24. int holeEndCol = width - wallThick;
  25.  
  26. for (int y = 1; y <= height; y++)
  27. {
  28. for(int x = 1; x <= width; x++)
  29. {
  30. if (y >= holeStartRow && y <= holeEndRow && x >=holeStartCol && x <= holeEndCol) {
  31. System.out.print(" ");
  32. } else {
  33.  
  34. System.out.print("*");
  35. }
  36.  
  37. }
  38. System.out.println();
  39. }
  40. }
  41. }
  42. }
Success #stdin #stdout 0.06s 2841600KB
stdin
Standard input is empty
stdout
*****
*****
** **
** **
*****
*****