Results 1 to 4 of 4

Thread: Array and math calculation

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    27

    Question Array and math calculation

    I have to create a program the enters a student name in one textbox (txtName.Text), takes their test grades from three other textboxes and calculates their individual average to output it (lstnames.text) and then calculates the average of all of the students to output (lblClassOutput.Text).

    My instructions state to declare an integer counter and a 10-by-2 string array as instance variables. Then store the student's name in the first column of the array and the student's average in the second column. The class average should be calculated using a function procedure.

    My code is below and it is obviously far from where it is needs to be.

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

    Dim name As String = txtName.Text
    Dim Test1 As Integer = txtTest1.Text
    Dim Test2 As Integer = txtTest2.Text
    Dim Test3 As Integer = txtTest3.Text
    Dim Average As Integer
    Dim TotalAvg As Integer
    Dim stroutput As String

    Dim ClassAvg(,) As String = New String(1, 9) {} _


    Average = (Test1 + Test2 + Test3) / 3

    stroutput = (String.Format("{0:c}", Average) & ControlChars.CrLf)

    lstNames.Text = stroutput

    End Sub
    End Class ' FrmStudentGrades

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    27

    Re: Array and math calculation

    Follow the URL to see what the form looks like:

    http://i33.photobucket.com/albums/d88/bbanis2k/Form.jpg

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Array and math calculation

    Quote Originally Posted by houdini
    I have to create a program.....My code is below and it is obviously far from where it is needs to be.....
    I didn't see any questions in your posts. We won't do your assignments for you, however; we will be happy to help with specific questions if you have any.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    27

    Re: Array and math calculation

    I'm not sure how to structure the array for the calcuations.

    I figured out the integer counter though:

    For intcounter = 1 To 10 Step 1
    Average = (Test1 + Test2 + Test3) / 3
    Next

    stroutput = (String.Format("{0:c}", Average) & ControlChars.CrLf)

    lstNames.Text = stroutput


    Like that?

    Where does the array come into play?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width