0

Good morning,

Can someone help me code this instruction?

Place student names and final mark into two, one- dimensional arrays. One array will be of String (for names), the other will be an array for real numbers (for marks)

Use the array to display:
Class Average
The number of students above the class average
3
Contributors
7
Replies
29
Views
4 Years
Discussion Span
Last Post by Begginnerdev
0

one dimensional array, and trying to figure out if I should used a public sub or public function to declare and get result

0

for example:

Public Function ClassAverage(ByVal Average As String)

    Dim Grades() As Decimal = {76.5D, 63.4D, 45.4D, 94.5D, 81.3D, 66.2D, 68.6D}
    Dim sum As Decimal = 0

    For intCounter As Integer = 0 To Grades.Length - 1
        sum += Grades(intCounter)
    Next

    Average = (sum / Grades.Length)

    Return Average

End Function

I HAVE TWO ERRORS THAT I DON'T UNDERSTAND
0

Don't know about your two errors, you don't explain them.
Perhaps as a start you could try this:
Public Function ClassAverage(ByVal grades As Decimal()) As Decimal

0

My errors have gone and I have asked Grades to return. Now when I go to write:

FileOpen(2, strFilename, OpenMode.Append)
            Write(Grades + vbTab + vbCrLf + vbCrLf)
            FileClose()



        I have an error: Grades is not declared
0

Have you declared Grades?

Do you mean something like this:

Dim Grades As Decimal = ClassAverage("TESTSTRING")

Edited by Begginnerdev

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.