Pattern Program using Java
As we have learnt so many Pattern Programs using C Language, Now We are going to explain a Pattern Program of Multiple Pyramid using Java Code. Here we have used Nesting of For Loops and If conditions.
/**
*
* @author Jadeja
*/
public class Pattern {
public static void main(String []a){
for(int i=1;i<=10;i++){
for(int j=1;j<=i;j++){
System.out.print(" ");
}
for(int j=1;j<=21;j++){
if(j<= 11-i)
System.out.print("O ");
else if (j<=10+i)
System.out.print("MM");
else
System.out.print(" E ");
}
System.out.println();
}
}
}
Output of the Program
As we have used Java Language for the same but it can also be written using C or C++ Language.