fork 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. class Ideone {
  9.  
  10. public static void main(String[] args) {
  11. int n = 1;
  12.  
  13. if(n == 1){
  14. System.out.println("Number Should Not Be 1");
  15. }
  16. boolean state = true;
  17.  
  18. for(int i = 2 ; i <=n ; i++){
  19. if(n%i == 0){
  20. state = true;
  21. }
  22. }
  23.  
  24. if(state == false){
  25. System.out.println("Number Should be Odd except 1");
  26. }
  27.  
  28. printPattern(n);
  29. }
  30.  
  31. public static void printPattern(int n) {
  32. int totalRows = n + 2;
  33. int totalCols = n*2;
  34.  
  35.  
  36. for (int row = 1; row <= totalRows; row++) {
  37. for (int col = 1; col <= totalCols; col++) {
  38.  
  39. if (row <= n) {
  40.  
  41. if (col == totalCols) {
  42. System.out.print("e");
  43. } else {
  44. System.out.print(" ");
  45. }
  46. } else if (row == n + 1) {
  47.  
  48. if (n == 3 && col == 2) {
  49. System.out.print("*");
  50. } else if (n != 3 && col == n + 1) {
  51. System.out.print("*");
  52. } else if (col == totalCols) {
  53. System.out.print("e");
  54. } else {
  55. System.out.print(" ");
  56. }
  57. } else {
  58.  
  59. if (col <= 3) {
  60. System.out.print("*");
  61. } else {
  62. System.out.print("e");
  63. }
  64. }
  65. }
  66. System.out.println();
  67. }
  68. }
  69. }
Success #stdin #stdout 0.08s 52660KB
stdin
Standard input is empty
stdout
Number Should Not Be 1
 e
 *
**