Solution:
Code:
Copyable code:
Module VBModule
'Structure definition
Structure Posts
Public userName As String
Public noPosts As Integer
End Structure
'Variable declaration
Dim arrOfPosts(15) As Posts
Dim i As Integer
'Sub for getting input
Sub input()
'Loop
For i=0 to 15
Console.WriteLine("Enter the user name"&i)
arrOfPosts(i).userName=Console.ReadLine()
Console.WriteLine("Enter Number of posts"&i)
arrOfPosts(i).noPosts=Console.Read()
Next i
End Sub
'Function to Find average
Function average() as double
Dim sum,ave as Double
sum=0
'Loop
For i=0 to 15
sum=sum+arrOfPosts(i).noPosts
Next i
ave=sum/15
average=ave
End Function
'Sub to find zero number of posts
Sub zeroPosts()
'Loop
For i=0 to 15
'Condition
If(arrOfPosts(i).noPosts=0)Then
Console.WriteLine("UserName with zero posts
is:"&arrOfPosts(i).userName)
End If
Next i
End Sub
'main Sub
Sub Main()
'Call the procedures and functions
input()
Console.WriteLine("Average:"&average())
zeroPosts()
End Sub
End Module
Get Answers For Free
Most questions answered within 1 hours.