Answer to Question #267968 in Visual Basic for ray

Question #267968

How to code procedures in a form to : i. A function that calculates average score. ii. Another function that determines the minimum score. iii. And another to determine the maximum score.


1
Expert's answer
2021-11-25T16:24:45-0500
Imports System.IO


Module Module1
    Sub Main()
        Dim score() As Integer = {85, 80, 88, 55, 25}




        Console.WriteLine("The average score is: " & determineAverageScore(score).ToString())
        Console.WriteLine("The minimum score is: " & determineMinimumScore(score).ToString())
        Console.WriteLine("The maximum  score is: " & determineMaximumScore(score).ToString())




        Console.ReadLine()
    End Sub




    Function determineAverageScore(ByVal score() As Integer)
        Dim sum As Double = 0
        For i As Integer = 0 To score.Length - 1
            sum += score(i)
        Next
        Return sum / score.Length
    End Function


    Function determineMinimumScore(ByVal score() As Integer)
        Dim min As Integer = score(0)
        For i As Integer = 1 To score.Length - 1
            If (score(i) < min) Then
                min = score(i)
            End If
        Next
        Return min
    End Function


    Function determineMaximumScore(ByVal score() As Integer)
        Dim max As Integer = score(0)
        For i As Integer = 1 To score.Length - 1
            If (score(i) > max) Then
                max = score(i)
            End If
        Next
        Return max
    End Function


End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS