Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

THIS HAS 2 PARTS 1) Write an application that displays the following patterns se

ID: 3809795 • Letter: T

Question

THIS HAS 2 PARTS

1)

Write an application that displays the following patterns separately, one below the other.

Use for loops to generate the patterns.

All asterisks (*) should be printed by a single statement of the form System. out. print( '*' ); which causes the asterisks to print side by side.

A statement of the form System. out. println(); can be used to move to the next line.

A statement of the form System. out. print( ' ' ); can be used to display a space for the two patterns. There should be no other output statements in the program.

Save the file as TrianglePrinting.java.

2)

Also create an application/project called TrianglePrintingTest.java class that has the main method and an object in order to use the TrianglePrinting class.

[PATTERNS ARE SHOWN BELOW]

Pattern 1.                                                                                                                                                                                            *

                **

                ***

                ****

                *****

                ******

                *******

                ********

                *********

**********

Pattern 2.

                **********

                *********

                ********

                *******

                ******

                *****

                ****

                ***

                **

                *

Explanation / Answer

1)

TrianglePrinting.java

public class TrianglePrinting {
   //This method prints the two triangle patterns
   public void printTriangle()
   {
       //displaying the first triangle
       for(int i=1;i<=10;i++)
       {
           for(int j=1;j<=i;j++)
           {
               System.out.print('*');
           }
           System.out.println();
       }
      
       System.out.println(' ');
      
       //displaying the second triangle
       for(int i=10;i>=0;i--)
       {
           for(int j=1;j<=i;j++)
           {
               System.out.print('*');
           }
           System.out.println();
       }
   }

}

____________________

2)

TrianglePrintingTest.java

public class TrianglePrintingTest {

   public static void main(String[] args) {
       //Creating the object of the TrianglePrinting class object
       TrianglePrinting tp=new TrianglePrinting();
      
       //calling the method on the TrianglePrinting class obejct
       tp.printTriangle();

   }

}

____________________

output:

*
**
***
****
*****
******
*******
********
*********
**********

**********
*********
********
*******
******
*****
****
***
**
*

__________Thank You