Question

In: Computer Science

Write a program that displays the following patters separately, one below the other in a TextBox.

(Triangles of Asterisks)

Write a program that displays the following patters separately, one below the other in a TextBox.

Use For..Next loops to generate the patterns. All asterisks (*) should be displayed one at a time by the statement outputTextBox.AppendText(“*”) (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. [Hint: The last two patterns require that each line begin with an appropriate number of blanks.]

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.

(a)

(b)

(c)

(d)

*

**

***

****

*****

******

*******

********

*********

**********

**********

*********

********

*******

******

*****

****

***

**

*

**********

*********

********

   *******

    ******

     *****

      ****

       ***

        **

         *

*

        **

       ***

      ****

     *****

    ******

   *******

********

*********

**********

Solutions

Expert Solution

Public Class Form1
Private Sub btn_DisplayPatterns_Click(sender As Object, e As EventArgs) Handles btn_DisplayPatterns.Click

Dim r, c, sp As Integer


For r = 1 To 10
For c = 1 To r
OutputTextBox.AppendText("*")
Next c
OutputTextBox.AppendText(vbCrLf)
Next r


OutputTextBox.AppendText(vbCrLf)
OutputTextBox.AppendText(vbCrLf)



For r = 10 To 1 Step -1
For c = 1 To r
OutputTextBox.AppendText("*")
Next c
OutputTextBox.AppendText(vbCrLf)
Next r


OutputTextBox.AppendText(vbCrLf)
OutputTextBox.AppendText(vbCrLf)



For r = 1 To 10
For sp = 1 To r
OutputTextBox.AppendText(" ") 'Comment : one space
Next sp
For c = 10 To r Step -1
OutputTextBox.AppendText("*")
OutputTextBox.AppendText(" ") 'Comment : one space
Next c
OutputTextBox.AppendText(vbCrLf)
Next r

OutputTextBox.AppendText(vbCrLf)
OutputTextBox.AppendText(vbCrLf)


For r = 1 To 10
For sp = 10 To r Step -1
OutputTextBox.AppendText(" ") 'Comment : one space
Next sp
For c = 1 To r
OutputTextBox.AppendText("*")
OutputTextBox.AppendText(" ") 'Comment : one space
Next c
OutputTextBox.AppendText(vbCrLf)
Next r

End Sub

Private Sub btn_exit_Click(sender As Object, e As EventArgs) Handles btn_exit.Click
Me.Close()
End Sub
End Class


Related Solutions

Create a C# Windows Console application that displays the following patterns separately, one after the other....
Create a C# Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the...
Write a method that displays every other element of an array. Write a program that generates...
Write a method that displays every other element of an array. Write a program that generates 100 random integers between 0 and 9 and displays the count for each number. (Hint: Use an array of ten integers, say counts, to store the counts for the number of 0s, 1s, . . . , 9s.) Write two overloaded methods that return the average of an array with the following headers:      public static int average(int[] intArray)        public static double average(double[] dArray) Also,...
JAVA program. Write two public classes (named exactly), TextBox and TextBoxTester.  TextBox contains the following overloaded static...
JAVA program. Write two public classes (named exactly), TextBox and TextBoxTester.  TextBox contains the following overloaded static methods called textBoxString. This method returns a String value. public static String textBoxString (int side) The returned String value, when printed, displays as the outline of a square of side characters. The character you use is up to you. Don't forget that '\n' will force a newline character into the returned String. For example, let's assume I want to use * as the character...
Java Programming Write a program that displays the following pattern *                         *       &nbsp
Java Programming Write a program that displays the following pattern *                         *          *          * *          *          *          *          *          *          *          *          *          *          *          *             *          *          *          *          *                         *          *          *                                     * Printing Pattern A * ** *** **** ***** ****** ******* Printing Pattern B ******* ****** ***** **** *** ** * Printing Pattern C * ** *** **** ***** ****** *******
Write a full program that solves the following equation and displays the value for x and...
Write a full program that solves the following equation and displays the value for x and y: 3.4x+50.2y=44.5 2.1x+.55y=5.9
IN PYTHON: Write a program that displays the lines from the total.txt file in the following...
IN PYTHON: Write a program that displays the lines from the total.txt file in the following output. Use a try catch phrase to check for errors. Use only one function for this portion [main()]. Remember to use Python. Sample output below: 19 16, 29 3, 30 4, 34
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
I need to write this program in Python. Write a program that displays a temperature conversion...
I need to write this program in Python. Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The tabular format of the result should include rows for all temperatures between 70 and 270 degrees Celsius that are multiples of 10 degrees Celsius (check the sample below). Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit is as follow F=(9/5C) +32 Celsius Fahrenheit 70 158 80 176 90...
Write a program that displays a frame containing two labels that display your name, one for...
Write a program that displays a frame containing two labels that display your name, one for your first name and one for your last. Experiment with the size of the window to see the labels change their orientation to each other. USE FIRST NAME: Aya LAST NAME: KAYED. SEND THE CODE IN THE EXACT FORMAT FOR JAVA ECLIPSE. I WILL COPY AND PASTE THE CODE SO I CAN RUN IT.
Write a Java program that reads a name and displays on the screen.
Write a Java program that reads a name and displays on the screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT