^_^The code is very short one that I remember I teacher show me before but I cannot remember. This may be long to read but the code is really simple plz here me Im new to C#. There are 3 steps needing to change the program.

1)*Never disabling the add grade button*
remove the code from the btnAdd_click event handler so that the Add Grade Button is not disabled after entering 10 grades.

2)*Summing the grades in the ListBox.*
modify code in the btnAverage_Click event handler so that inGradeCounter is incremented until it is equal to the number of grades entered. Use lstGrades.Items.Count to determine the number of items in the Listbox. The number returned by the Count property will be zero if there are no grades entered. Use an if selection statement to avoid division by zero and display a message dialog to the user if there are no grades entered when the user clicks the Average button.

3)*Calcualting the class average*
Modify the code in the btnAverage_Click event handler so that dblAverage is computed by using intGradeCounter rather than the Value 10.


I had the statment in short for some of the main code
Code: C#
static void Main()
     {
        Application.Run( new FrmClassAverage() );
     }

     // handles Add Grade Button's Click event
     private void btnAdd_Click(
        object sender, System.EventArgs e )
     {
        // clear previous grades and calculation result
        if ( lblOutput.Text != "" )
        {
           lblOutput.Text = "";
           lstGrades.Items.Clear();
        }

        // display grade in ListBox
        lstGrades.Items.Add( Int32.Parse( txtInput.Text ) );
        txtInput.Clear(); // clear grade from TextBox
        txtInput.Focus(); // transfer focus to TextBox

        // prohibit users from entering more than 10 grades
        if ( lstGrades.Items.Count == 10 )
        {
           btnAdd.Enabled = false; // disable Add Grade Button
           btnAverage.Focus(); // transfer focus to Average Button
        }

     } // end method btnAdd_Click

     // handles Average Button's Click event
     private void btnAverage_Click(
        object sender, System.EventArgs e )
     {
        // initialization phase
        int intTotal = 0;
        int intGradeCounter = 0;
        int intGrade = 0;
        double dblAverage = 0;

        // sum grades in ListBox
        do
        {
           // read grade from ListBox
           intGrade = ( int )
              lstGrades.Items[ intGradeCounter ];
           intTotal += intGrade; // add grade to total
           intGradeCounter++; // increment counter
        } while ( intGradeCounter < 10 );

        dblAverage = intTotal / 10.0; // calculate average
        lblOutput.Text = String.Format( "{0:F}", dblAverage );
        btnAdd.Enabled = true; // enable Add Grade Button
        txtInput.Focus(); // reset focus to Enter grade: TextBox

     } // end method btnAverage_Click

  } // end class FrmClassAverage
}