Post a New Question

Computer programming

posted by .

The code below is supposed to calculate the average for a student using 10 grades. It contains several errors. Rewrite the code using the correct naming conventions and turn in the full solution and discuss using this topic.

Dim arrGrades(10) as integer
Dim num,I, iAverage as Integer

For I = 1 to 10
Num = inputboxl(“Please enter a number”)
arrGrades(10) = num
iAverage = arrGrades(9) / 10

  • Computer programming -

    There are many programming languages. You're using Basic, which exists in many flavours. You may want to specify the name of the compiler (VB?) you're using.

    1. An average is generally a floating point number, so it should not be defined as an integer.
    2. Inputbox returns a string. You may want to convert it to an integer using CInt (or CDec)
    3. There is no variable to accumulate the total marks.
    4. Average is obtained by dividing the total by the number of marks (10).
    5. next I is better than next by trying to avoid nesting errors.
    6. There is no error trapping. For example, if the user types in an invalid number, there should be a check and have the user re-enter the value.

Answer This Question

First Name:
School Subject:

Related Questions

More Related Questions

Post a New Question