Exercise
Hollow rectangle
Objetive
Write a Visual Basic (VB.Net) program that prompts for a symbol, a width, and a height, and displays a hollow rectangle of that width and height, using that symbol for the outer border, as in this example:
Enter a symbol: 4
Enter the desired width: 3
Enter the desired height: 5
444
4 4
4 4
4 4
444
Code
Imports System
Public Class exercise42
Public Shared Sub Main()
Dim row, column As Integer
Console.Write("Enter a symbol: ")
Dim symbol As Integer = Convert.ToInt32(Console.ReadLine())
Console.Write("Enter the desired width: ")
Dim width As Integer = Convert.ToInt32(Console.ReadLine())
Console.Write("Enter the desired height: ")
Dim height As Integer = Convert.ToInt32(Console.ReadLine())
Console.WriteLine()
For row = 1 To height
For column = 1 To width
If (row = 1) OrElse (row = height) Then
Console.Write(symbol)
Else
If (column = 1) OrElse (column = width) Then
Console.Write(symbol)
Else
Console.Write(" ")
End If
End If
Next
Console.WriteLine()
Next
End Sub
End Class