Computer Science, asked by BrainlyProgrammer, 2 months ago

[SUPER CHALLENGE]

Make your own Java Códe to get the following 'W' pattern as output.

, ,,,,,,,, ,
,, ,,, ,,, ,,
,,, ,, ,, ,,,
,,,,, ,,,,,

Hint:- The above pattern contains 6 triangle pattern and 1 pyramid pattern.
_
• CORRECT PATTERN IS GIVEN IN ATTACHMENT. If it is not properly given in the question Check The ATTACHMENT.

• Do not be greedy of points.
• Do not spam or post copied answers.
• Try your best! Good Luck!

Attachments:

TheMoonlìghtPhoenix: Good Question 0.0

Answers

Answered by Oreki
9

\text{\large\bf Algorithm}

    \textsf{\textemdash \: Setting the initial pattern/line.}\\\textsf{\textemdash \: Adding new dots after and before the two right-triangles respectively.}\\\textsf{\textemdash \: Deleting two dots in the middle to make a pyramid pattern.}\\\textsf{\textemdash \: } {\sf Rep eating} \textsf{ until the pattern is complete.}

More questions related to String Manipulation -

  • https://brainly.in/question/37937856
  • https://brainly.in/question/35135863
  • https://brainly.in/question/33815868
  • https://brainly.in/question/13379846
  • https://brainly.in/question/21529758
Attachments:
Answered by anindyaadhikari13
11

Solution:

Here comes my approach.

public class Pattern    {

   public static void main(String args[]){

       int i;

       for(i=1;i<=4;i++){

           dots(1,i);

           spaces(i,3);

           dots(i,4);

           spaces(3,2*i);

           dots(i,4);

           spaces(i,3);

           dots(1,i);

           System.out.println();

       }

   }

   static void dots(int i,int j){

       for(int k=i;k<=j;k++)

           System.out.print(".");

   }

   static void spaces(int i,int j){

       for(int k=i;k<=j;k++)

           System.out.print(" ");

   }

}

There are two functions - dots(i,j) and spaces(i,j).

  • dots(): This function creates dots in the pattern.
  • spaces(): This function creates spaces between the dots where necessary.

Both functions are called inside the loops. Hence the pattern is printed.

See the attachment for output.

•••♪

Attachments:
Similar questions