In: Computer Science
*VISUAL BASIC* Construct and instantiate an array of strings called afcSouth that contains the following information separated by commas (as team, wins, losses, and ties). You realize now that you need to compute a winning percentage (namely (wins+.5*ties)/(wins + losses+ties)) for these teams. Use this array to create a structure afcSouthTeam consisting of types string, integer, integer, integer, and double. Write a for loop that will cycle through the array to populate this structure with the actual data.
Following is the Code:
Imports System
Public Structure afcSouthTeam 'Create structure
Public teamName As String
Public wins As Integer
Public loses As Integer
Public ties As Integer
Public winPercent As Double
End Structure
Class MyClient
Public Shared Sub Main()
Dim afcSouth() As String =
{"TeamA", "10", "5", "2"}
Dim team as New afcSouthTeam
Dim j As Integer
For j = 0 To 4
If (j <>
0) Then
team.teamName = afcSouth(0)
End if
If (j <>
1) Then
team.wins = CInt(afcSouth(1)) 'Convert String to
Integer
End if
If(j <> 2)
Then
team.loses = CInt(afcSouth(2)) 'Convert String
to Integer
End if
If(j <> 3)
Then
team.ties = CInt(afcSouth(3)) 'Convert String to
Integer
End if
If(j <> 4)
Then 'Computer results in double datatype
team.winPercent = (team.wins + (0.5) *
team.ties) / (team.wins + team.loses + team.ties)
End if
Next j
Console.WriteLine("The TeamName =
is {0}", team)
Console.WriteLine("The Wins - {0}",
team.wins)
Console.WriteLine("The Loses =
{0}", team.loses)
Console.WriteLine("The Ties = {0}",
team.ties)
Console.WriteLine("The Win
Percentage = {0}", team.winPercent)
End Sub 'Main
End Class 'MyClient