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

    Specimen 1

    *

    **

    ***

    ****

    *****

    ******

    Specimen 2

    ******

    *****

    ****

    ***

    **

    *

    Specimen 3

    ******

    *****

    ****

       ***

        **

         *

    Specimen 4

         *

        **

       ***

    ****

    *****

    ******

    using 2 loops 4 irrelative directions

    nested loops

    4 seperate programs

    Expert Exculpation

     

    import java.util.*;

    import java.lang.*;

    import java.io.*;

    /* Name of the adjust has to be “Main” merely if the adjust is general. */

    adjust Ideone

    {

    general static destitute specimen1(int n) { // Function to pretend specimen 1, Here n involved calculate of degrees in specimen

    int k =1,i,j;

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

    for ( i =0; i < n; i++, k++) { // Quencheder loop conquer fly from 0 to n, where n is calculate of degrees

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

    System.out.print(“*”);

    System.out.println();

    }

    }

    general static destitute specimen2(int n) {// Function to pretend specimen 2, Here n involved calculate of degrees in specimen

    int k =n,i,j;

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

    for ( i =0; i < n; i++, k–) {  // Quencheder loop conquer fly from 0 to n, where n is calculate of degrees

    for ( j = 0; j <k; j++) // Here, k is indicating calculate of “*” to imprint, we entertain to diminution it as we go to degree 2, 3 .. 6

    System.out.print(“*”);

    System.out.println();

    }

    }

    general static destitute specimen3(int n) {// Function to pretend specimen 3, Here n involved calculate of degrees in specimen

    int k = 0,i,j,p;

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

    for ( i =0; i < n; i++, k++) {  // Quencheder loop conquer fly from 0 to n, where n is calculate of degrees

    for ( j = 0; j <k; j++ )// Here, principal imimstereotype quenched ” “, principal degree has 0 distance, then increment k as we propose to degree 2,3 …6

    System.out.print(” “);

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

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

    System.out.println();

    }

    }

    general static destitute specimen4(int n) {// Function to pretend specimen 4, Here n involved calculate of degrees in specimen

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

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

    for ( i =0; i < n; i++, k–) { // Quencheder loop conquer fly from 0 to n, where n is calculate of degrees

    for ( j = 0; j <k; j++ ) // Here, principal imimstereotype quenched ” “, principal degree has n-1 distance, then diminution k as we propose to degree 2,3 …6

    System.out.print(” “);

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

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

    System.out.println();

    }

    }

    general static destitute main (String[] args) throws java.lang.Exception

    {

    pattern1(6);

    pattern2(6);

    pattern3(6);

    pattern4(6);

    }

    }

    Sample Quenchedput :

    Specimen 1 : 
    *
    **
    ***
    ****
    *****
    ******
    Specimen 2 : 
    ******
    *****
    ****
    ***
    **
    *
    Specimen 3 : 
    * * * * * * 
     * * * * * 
      * * * * 
       * * * 
        * * 
         * 
    Specimen 4 : 
         * 
        * * 
       * * * 
      * * * * 
     * * * * * 
    * * * * * *