Below is an assignment that i did but i didnt do good on it. It is/was never meant to be ran the teacher was just asking for the code to be written based off of her A-D. Can you please let me know what is right and wrong with this.

This is using VBScript

The parts of this ? are all continuations of each other. U may assume
code written for the later portions of the ? uses the results of the previous
parts of the ?.

A. Write a line of code to create an array called aScores that will have 10 values.

Dim aScores(9)

B. Set up a loop that will allow the user to enter 10 values into consecutive
locations in the array aScores.

ReDim aScores(iCount)

For t = 1 to 10 vInput = InputBox("Enter Score: " & cstr(t), "Question: " & cstr(t)) If isNumeric(vInput) Then
aScores(t) = cInt(vInput)
Else
aScores(t) = 0
End If

C. Assume that a variable named ScoreAverage exists and has been assigned the
value of 0 (zero). Set up a loop and any additional statements necessary to
calculate the average of the values in aScores. The average should be assigned to
ScoreAverage.

ScoreAverage = 0

ScoreAverage = ScoreAverage + aScores(t)

Next ScoreAverage = cint(ScoreAverage/10)

D. Assume that a variable called HighCount exists and has been assigned the value of
0 (zero). Set up a loop to count the number of values in the array that exceed the
average. That number should be assigned to HighCount.


HighCount = 0

For t = 1 to iCount ScoreAverage = ScoreAverage + aScores(t)

If aScores(q) > iAvg Then
ScoreAverage = ScoreAverage + 1
End If

Just a quick critique. By item:
A. Good. Just be aware that this will be indexed as aScores(0) through aScores(9)
B. No need to redim if it isn't changing the array size.
You have a "FOR" with no "NEXT".
You cycle through from 1 to 10. You should be cycling through from 0 to 9 (see above).
C. You have a "NEXT" with no "FOR". Sum the scores inside the "FOR/NEXT" construct, then divide after the loop is done.
D. You have a "FOR" with no "NEXT".
You cycle from 1 to iCount. That variable has never been set to a value.

Nevermind, VBScript. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.