CODING JOY

The stunning potpourri of coding and mundane life

PLUS SIGN IN JAVA LANGUAGE



AMRUHA AHMED
14th December,2023.



This article will aid you in the creation of a plus sign in Java using a combination of nested loops. blog1

DELVING DEEPER:

BREAK-UP OF THE PATTERN:

blog1

PROGRAM:

                
                    import java.util.*;
                    class pluspattern
                    {
                    void main()
                    {
                        int m=5;//spaces before the *
                        int i,j;//loop counters
                        for(i=1;i<=11;i++)
                        {
                            if(i!=6)//when the iteration hasn't reached the middle of the pattern
                            {
                                for(j=1;j<=m;j++)
                                System.out.print("  ");
                                System.out.print("* ");
                            }
                            else//outer loop has reached the middle of the pattern
                            {
                                for(j=1;j<=11;j++)//printing the horizontal line
                                System.out.print("* ");
                            }
                            System.out.println();
                        }
                    }
                    }                                                       
             
         
CODE COPIED

OUTPUT:

blog1