Homework Solution: JAVA Assignment…

    JAVA Assignment Use JCreator to solve Pattern 1 * ** *** **** ***** ****** Pattern 2 ****** ***** **** *** ** * Pattern 3 ****** ***** ****    ***     **      * Pattern 4      *     **    *** **** ***** ****** using 2 loops 4 different directions nested loops 4 seperate programs

    Expert Answer

     
    import java.util.*; import java.lang.*;

    JAVA Assignment

    Use JCreator to solve

    Sample 1

    *

    **

    ***

    ****

    *****

    ******

    Sample 2

    ******

    *****

    ****

    ***

    **

    *

    Sample 3

    ******

    *****

    ****

       ***

        **

         *

    Sample 4

         *

        **

       ***

    ****

    *****

    ******

    using 2 loops 4 contrariant directions

    nested loops

    4 seperate programs

    Expert Retort

     

    import java.util.*;

    import java.lang.*;

    import java.io.*;

    /* Name of the systematize has to be “Main” solely if the systematize is exoteric. */

    systematize Ideone

    {

    exoteric static wanting sample1(int n) { // Function to assume sample 1, Here n implied estimate of degrees in sample

    int k =1,i,j;

    System.out.println(“Sample 1 : “);

    for ( i =0; i < n; i++, k++) { // Extinguisheder loop accomplish leak from 0 to n, where n is estimate of degrees

    for ( j = 0; j <k; j++) // Here, k is indicating estimate of “*” to sculpture, we enjoy to increment it as we go to degree 2, 3 .. 6

    System.out.print(“*”);

    System.out.println();

    }

    }

    exoteric static wanting sample2(int n) {// Function to assume sample 2, Here n implied estimate of degrees in sample

    int k =n,i,j;

    System.out.println(“Sample 2 : “);

    for ( i =0; i < n; i++, k–) {  // Extinguisheder loop accomplish leak from 0 to n, where n is estimate of degrees

    for ( j = 0; j <k; j++) // Here, k is indicating estimate of “*” to sculpture, we enjoy to adulteration it as we go to degree 2, 3 .. 6

    System.out.print(“*”);

    System.out.println();

    }

    }

    exoteric static wanting sample3(int n) {// Function to assume sample 3, Here n implied estimate of degrees in sample

    int k = 0,i,j,p;

    System.out.println(“Sample 3 : “);

    for ( i =0; i < n; i++, k++) {  // Extinguisheder loop accomplish leak from 0 to n, where n is estimate of degrees

    for ( j = 0; j <k; j++ )// Here, primitive sculpture extinguished ” “, primitive degree has 0 immeasurableness, then increment k as we agitate to degree 2,3 …6

    System.out.print(” “);

    for ( j = 0; j <n-k; j++)

    System.out.print(“* “); //Here sculptureing “* ”

    System.out.println();

    }

    }

    exoteric static wanting sample4(int n) {// Function to assume sample 4, Here n implied estimate of degrees in sample

    int k = n-1,i,j,p;

    System.out.println(“Sample 4 : “);

    for ( i =0; i < n; i++, k–) { // Extinguisheder loop accomplish leak from 0 to n, where n is estimate of degrees

    for ( j = 0; j <k; j++ ) // Here, primitive sculpture extinguished ” “, primitive degree has n-1 immeasurableness, then adulteration k as we agitate to degree 2,3 …6

    System.out.print(” “);

    for ( j = 0; j <n-k; j++)

    System.out.print(“* “);  //Here sculptureing “* ”

    System.out.println();

    }

    }

    exoteric static wanting main (String[] args) throws java.lang.Exception

    {

    pattern1(6);

    pattern2(6);

    pattern3(6);

    pattern4(6);

    }

    }

    Sample Extinguishedput :

    Sample 1 : 
    *
    **
    ***
    ****
    *****
    ******
    Sample 2 : 
    ******
    *****
    ****
    ***
    **
    *
    Sample 3 : 
    * * * * * * 
     * * * * * 
      * * * * 
       * * * 
        * * 
         * 
    Sample 4 : 
         * 
        * * 
       * * * 
      * * * * 
     * * * * * 
    * * * * * *