-
Get Average of Array - Visual Basic 2003
Hey Everyone!
I am writing a simple program that calculates the average grades from user input.
I need help with the following:
1) I have been getting the average of an array by doing the following Sub calcAverage()
average = grades(1) + grades(2) + grades(3) + grades(4) + grades(5) / 5
End Sub
2)Is there a way to combine this with the function to add grades to the array and use the lower and upper bounds to determine what the denominator will be?
Here is the code for the array:
Sub sortarray()
Array.Sort(grades)
For i As Integer = 1 To 5
sortedArray(i) = (grades(i))
Next
End Sub
THANKS for looking this over!
-
sorry it seems like every time i write it out, i am able to figure it out. of course if there is an alternative way of doing this please let me know.This is what I came up with.
Sub sortarray()
Array.Sort(grades)
For i As Integer = 1 To 5
sortedArray(i) = (grades(i))
sum = sortedArray(i) + sum
count = count + 1
average = sum / count
Next
End Sub
Similar Threads
-
By Zahid Iqbal in forum dotnet.announcements
Replies: 0
Last Post: 05-20-2003, 07:06 AM
-
By Constance J. Petersen in forum dotnet.announcements
Replies: 0
Last Post: 11-22-2002, 10:40 AM
-
By Constance J. Petersen in forum dotnet.announcements
Replies: 0
Last Post: 07-26-2002, 03:32 PM
-
By Yair Alan Griver [MS] in forum vb.announcements
Replies: 0
Last Post: 04-11-2002, 08:33 PM
-
By Pierluigi in forum VB Classic
Replies: 0
Last Post: 07-25-2000, 10:28 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|