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

Write a java application that displays the following patterns separately one bel

ID: 3670132 • Letter: W

Question


Write a java application that displays the following patterns separately one below the other.
Use for loops to generate the patterns. There are 4 Triangle patterns.
All asterisks (*) should be printed by a single statement of the form System.out.print('*');
This is 4-different patterns, not 1-pattern.

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

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

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

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

Explanation / Answer

public class numPtr {
    public static void main( String arg[]){
        int c=2,d=0;
        for(int i=1;i<=10;i++){

            for(int j=1;j<=i;j++){
                System.out.print("*");
            }
            System.out.println();
        }
        for(int i=1;i<=10;i++){
            for(int j=10;j>=i;j--){
                System.out.print("*");
            }
            System.out.println();
}

        while(c>0){
        if(d==0){
            for(int i=1,r=10;i<=10;i++,r--){
            for(int j=1;j<=r;j++){
                System.out.print("*");
            }
            System.out.println();        }
            d++;
       } else{
            for(int i=1;i<=10;i++){
            for(int j=1;j<=i;j++){
                System.out.print("*");            }
            System.out.println();
        }
        }
        c--;
}
       
       
       
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote