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...
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 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
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...
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...
Write an assembly program that displays the following two options: 1. Display the current date. 2....
Write an assembly program that displays the following two options: 1. Display the current date. 2. Enter a date for a meeting and display remaining days. If the user selects the first option, the program should display the current date in dd/mm/yyyy format. If the user selects the second option, the program asks the user to enter a date for a meeting within year 2020 (in decimal) in dd/mm format. The program then calculates and displays the number of days...
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents....
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents.  The formula for converting a temperature from Celsius to Fahrenheit is F = 9/ 5 C + 32 where F → Fahrenheit temperature C → Celsius temperature.  Allow the user to enter the range of temperatures in Celsius to be converted into Fahrenheit.  Your program must use a loop to display the values of the temperature conversions (see sample output). Sample...
Write a program named MakeChange that calculates and displays the conversion of an entered number of...
Write a program named MakeChange that calculates and displays the conversion of an entered number of dollars into currency denominations—twenties, tens, fives, and ones. For example, if 113 dollars is entered, the output would be twenties: 5 tens: 1 fives: 0 ones: 3. Answer in C# (P.S i'm posting the incomplete code that i have so far below.) using System; using static System.Console; class MakeChange { static void Main() { int twenties, tens, fives, ones; WriteLine("Enter the number of dollars:");...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT