Exercise
Centered triangle
Objetive
Write a Visual Basic (VB.Net) program that Display a centered triangle from a string entered by the user:
__a__
_uan_
Juan
Code
Imports System
Public Class exercise85
Public Shared Sub Main()
Dim name As String
Console.Write("Enter your name: ")
name = Console.ReadLine()
If name.Length Mod 2 = 0 Then name += " "
Dim position As Integer = name.Length / 2
Dim maxRows As Integer = name.Length / 2 + 1
Dim amount As Integer = 1
For i As Integer = 0 To maxRows - 1
For j As Integer = 0 To position - 1
Console.Write(" ")
Next
Console.WriteLine(name.Substring(position, amount))
position -= 1
amount += 2
Next
End Sub
End Class