First, let me apologize if this gets in the way of the normal forum. I am currently a student working on learning VBscript, and have a task to which I am trying to find the best solution.
If this violates any forum rules, or simply is not the place to post, please let me know so I can remove.
For any that would like to assist here is my problem...
Currently I have a script that is based on showing the maximum grade/mark for a student when prompting the user, however, what I am trying to do is re-write the script so it can provide a grade average rather than simply reflecting the maximum.
Below is the current script:
Function findmax(marks) ' defines a function findmax that takes an argument marks
Dim max
max = 1 ' initialize max to first student
For i=1 to 5 ' loop over the array marks
If marks(i)>marks(max) Then ' update max if ith student is having more marks
max=i
End If
Next
findmax=max ' return the value of marks
End Function
Dim marks(5) ' declare an array marks
' prompt user to enter data for 5 students and storing it in array marks
for i=1 to 5
marks(i) = InputBox("Enter the marks of student" & i, "Student " & i)
If marks(i) = "" Then
Wscript.Quit ' exit the program if user does not enter the value
End If
next
WScript.Echo "student having highest marks is " & findmax(marks) ' call the function findmax and pri nt the index of student with maximum marks
If anyone also knows of a forum area or website that would be more appropriate for this type of question please let me know.
Thank you in advance if anyone can provide assistance.
If this violates any forum rules, or simply is not the place to post, please let me know so I can remove.
For any that would like to assist here is my problem...
Currently I have a script that is based on showing the maximum grade/mark for a student when prompting the user, however, what I am trying to do is re-write the script so it can provide a grade average rather than simply reflecting the maximum.
Below is the current script:
Function findmax(marks) ' defines a function findmax that takes an argument marks
Dim max
max = 1 ' initialize max to first student
For i=1 to 5 ' loop over the array marks
If marks(i)>marks(max) Then ' update max if ith student is having more marks
max=i
End If
Next
findmax=max ' return the value of marks
End Function
Dim marks(5) ' declare an array marks
' prompt user to enter data for 5 students and storing it in array marks
for i=1 to 5
marks(i) = InputBox("Enter the marks of student" & i, "Student " & i)
If marks(i) = "" Then
Wscript.Quit ' exit the program if user does not enter the value
End If
next
WScript.Echo "student having highest marks is " & findmax(marks) ' call the function findmax and pri nt the index of student with maximum marks
If anyone also knows of a forum area or website that would be more appropriate for this type of question please let me know.
Thank you in advance if anyone can provide assistance.