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

(Trinagles of Asterisks) Write a program that displays the following patterns se

ID: 3676474 • Letter: #

Question

(Trinagles of Asterisks) Write a program that displays the following patterns separately, one bellow the other in a Textbox. Uses for...Next loops to generate the patterns. All asterisks (*) should be displayed one at a time by the statement outputTextBox AppendTextr("*") (this causes the asterisks to display side by side). The statement OutputTextBox AppendText(vbCrLf) can be used to position to the next line, and a statement of the form outputTextBox AppendText (" ") can be used to display spaces for the last two patterns There should be no other output statements in the program. Maximize your use of repetition (with nested For...Next statements) and minimize the number of output statements. Set the TextBox's Font property to Lucida Console, its Multiline property to True and its ScrollBars property to Vertical so that you can scroll through the results.

Explanation / Answer

a)


public class star {
  
       public static void main (String[] args)
  
       {
  
          for (int count =0; count < 10; count++)
  
          {

            for (int j=0; j < count+1; j++)
  
               System.out.print("*");
  
            System.out.println();
  
          }
  
       }
  
       }

b)

import java.io.*;
public class star {

    public static void main(String[] args)throws IOException {

        InputStreamReader read = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(read);
        int i,j,n=0,k;
        System.out.print("Enter number ");
        n=Integer.parseInt(in.readLine());
        for (i = 0; i<n; i=i+2)
        {
            for (j=i; j<n;j++)
            System.out.print ("*");
            System.out.println();
        }
    }

}

c)


   public class star

  

   {

   public static void main (String[] args)

   {

            for(int count = 0; count < 10; count++)

            {

                for(int index=1; index < count+1; index++)

                    System.out.print(" ");

  

                for(int star=10; star > count; star--)

                    System.out.print("*");

                System.out.println();

            }

        }

   }

d)


   public class star{   {

   public static void main (String[] args)

      {

            for(int count = 10; count > 0; count--)

            {

                for(int index=0; index < count-1; index++)

                    System.out.print(" ");

               

                for(int star=10; star > count-1; star--)

                    System.out.print("*");

               

                System.out.println();

            }

   }