fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  5. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. import java.util.*;
  10. public class Main
  11. {
  12. public static void Pattern(int n){
  13. for(int i = 0; i<(n+2); i++){
  14. for(int j = 0; j<n+2; j++){
  15. System.out.print(" ");
  16. }
  17. for(int j = 0; j<n; j++){
  18. if(j== (n/2)){
  19. System.out.print("e");
  20. }else{
  21. System.out.print(" ");
  22. }
  23.  
  24. }
  25. System.out.println();
  26. }
  27. for(int i = 0; i<n+2; i++){
  28. for(int j = 0; j<n+2; j++){
  29. if(i == (n/2)+1){
  30. System.out.print("e");
  31. }else{
  32. System.out.print(" ");
  33. }
  34. }
  35. for(int j =0; j<n;j++){
  36. System.out.print("*");
  37. }
  38. System.out.println();
  39. }
  40. }
  41. public static void main(String[] args) {
  42. System.out.println("Hello World");
  43. Scanner sc = new Scanner(System.in);
  44. System.out.println("Enter Odd Value : ");
  45. int n = sc.nextInt();
  46. if((n%2 == 0) || (n < 0) || (n==1)) {
  47. System.out.println("Invalid Input");
  48. }
  49. else{
  50. Pattern(n);
  51. }
  52. }
  53. }
  54.  
Success #stdin #stdout 0.15s 54660KB
stdin
5
stdout
Hello World
Enter Odd Value : 
         e  
         e  
         e  
         e  
         e  
         e  
         e  
       *****
       *****
       *****
eeeeeee*****
       *****
       *****
       *****