fork download
  1. /******************************************************************************
  2.  
  3.   Online Java Compiler.
  4.   Code, Compile, Run and Debug java program online.
  5. Write your code in this editor and press "Run" button to execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. public class Main
  10. {
  11. public static void main(String[] args) {
  12.  
  13. int n = 5;
  14. if(n%2==0 || n<3 )
  15. {
  16. throw new ArithmeticException("Not a valid no , Please enter the odd no that should be greater than 1");
  17. }
  18. else
  19. {
  20.  
  21. for (int i=1;i<=n+2 ; i++)
  22. {
  23.  
  24. for(int j=1;j<=n-1;j++)
  25. {
  26. if(i==n+2)
  27. System.out.print("*");
  28. else
  29. System.out.print(" ");
  30. }
  31. for(int k=0;k<1;k++)
  32. {
  33. System.out.print("e");
  34. }
  35. for(int l=1;l<=n+2;l++)
  36. {
  37. if(i==1)
  38. {
  39. System.out.print("*");
  40. }
  41. else
  42. break;
  43. }
  44. for(int c=1;c<=n;c++)
  45. {
  46. if(i==(n/2)+2)
  47. {
  48. System.out.print("*");
  49. }
  50. else
  51. break;
  52. }
  53.  
  54. System.out.println("");
  55.  
  56. }
  57. }
  58.  
  59. }
  60. }
Success #stdin #stdout 0.07s 54668KB
stdin
Standard input is empty
stdout
    e*******
    e
    e
    e*****
    e
    e
****e