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...
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...
Write a program that displays a weekly payroll report. A loop in the program should ask...
Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: Do not accept negative numbers for any of the items entered. Do not...
c++ Write a program that displays the status of an order. a) Program uses 2 functions...
c++ Write a program that displays the status of an order. a) Program uses 2 functions (in addition to main ()). b) The first function asks the user for the data below and stores the input values in reference parameters. c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate. d) The second function receives as arguments any values needed to compute and display...
Write a program that accepts a string and character as input, then counts and displays the...
Write a program that accepts a string and character as input, then counts and displays the number of times that character appears (in upper- or lowercase) in the string. Use C++ Enter a string: mallet Enter a character: a "A" appears 1 time(s) Enter a string: Racecar Enter a character: R "R" appears 2 time(s)
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays the sum and the difference. In the .data section, define two variables num1 and num2 both words. Initialize num1 to 92413 10 and num2 to D4B 16 (use 0xD4B to initialize, Note that D4B is a hexadecimal number). Your main procedure/function should load the values of num1 and num2 into two temporary registers, and display them on the console window. Then add the values...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT