arrays

BTPH

New member
Joined
May 4, 2005
Messages
1
Programming Experience
Beginner
hi all, im new so im sorry if ive posted in the wrong place, this forum is jus so big, ive never seen a forum with this many different threads for posting,
\
anyway getting to my problem, ive got a class project in which i hasve to create a vb.net program that does the following

theyve given me a list of 20 numbers
0, 0, 5, 9, 44, 45, 46, 50, 50, 55, 62, 66, 73, 76, 77, 78, 80, 82, 84, 94
these numbers represent marks students got on tests, they have then given mne 5 different categories, N wich is makrs between 0 and 49, P 50 to 59, C 60 to 69, D 70 to 79 and HD 80 to 100

im supposed to make a program that calculates the count (which basically counts how many items in each categorey, or in more then one category depending on what has been selected), the Sum, the Mean and finally (the thing i hate most) standard deviation.

i have designed the interface and defined the array but i need help with the code, i do not want someone to do the whole thing for me as i want to complete this myself (thats the only way ill ever ba ble to learn) but if someone could do one calculation or just give me something to put me on the right track i would greatly appreciate it

ive attached what ive done so far

thank you,
ben
 

Attachments

  • WindowsApplication2.zip
    7.9 KB · Views: 41
I haven't looked at your code, but in this sort of situation I always use a SortedList of ArrayLists. In your case, each key in the SortedList would be the mark ("N", "P", "C", "D", "HD") and the corresponding value would be an ArrayList containing the scores that correspond to that mark:
VB.NET:
Dim scoreArray As Integer() = {...}
Dim scoreByMarkList As New SortedList

'Add each mark to the list.
scoreByMarkList.Add("N", New ArrayList)
'...

For Each score As Integer In scoreArray
	Select Case score
		Case < 50
 			scoreByMarkList("N").Add(score)
		Case < 60
 			scoreByMarkList("P").Add(score)
		Case < 70
 			scoreByMarkList("C).Add(score)
		Case < 80
 			scoreByMarkList("D").Add(score)
		Case Else
 			scoreByMarkList("HD").Add(score)
	End Select
Next
The list of scores for each mark is then accessed using scoresByMarkList(<mark>), which returns an Object that you should cast as an ArrayList. To get the number of scores that earned a credit, you would use:
VB.NET:
CType(scoresByMarkList("C"), ArrayList).Count
 
Back
Top