Write a vbscript to enter the following information into a 2D array and display it in a single msgbox with the header and calculated average GPA using loops
John EET 2.7
April NSA 3.5
Oliver NCM 3.8
Submit your lab as a single word document with the script and a screenshot of the output
Program:
'definition of a sub-procedure
sub info()
dim arr(3,3)
dim i,j
dim output
dim sum,avgGPA
sum=0.0
output="Student Information" & VbNewLine
output=output & "--------------------------" &
VbNewLine
arr(0,0)="John"
arr(0,1)="EET"
arr(0,2)=2.7
arr(1,0)="April"
arr(1,1)="NSA"
arr(1,2)=3.5
arr(2,0)="Oliver"
arr(2,1)="NCM"
arr(2,2)=3.8
for i=0 to 2
for j=0 to 2
output=output & arr(i,j) & " "
next
sum=sum+CDbl(arr(i,2))
output=output & VbNewLine
next
avgGPA=CDbl(sum/3)
output=output & "--------------------------" & VbNewLine
output=output & "Average GPA: " & Round(avgGPA,2)
msgbox(output)
end sub
'calling sub-procedure
info
Output:
Note :
To run VBScript i have used commandPrompt/Powershell using
command
cscript fileName.vbs
Example : cscript student.vbs
Write a vbscript to enter the following information into a 2D array and display it in...