6 Replies - 10535 Views - Last Post: 12 December 2013 - 08:32 AM Rate Topic: -----

#1 Naturalivity   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 12-December 13

Student Test Scores Array help

Posted 12 December 2013 - 08:04 AM

Sorry forgot to add code to my other post.... I have this problem:

Quote

A teacher has 6 students, and wants you to create an application that stores their grade data in a file and prints a grade report. The application should have structure that stores: Name (a string), Test Scores (an array of 5 doubles), and Average ( a double) . It should have an array of 6 structure variables to match the 6 students.It should allow the user to enter the data for each student, and calculate the average test score for each. The user needs to be able to save, read and print data to/from file etc.

It should not accept scores below 0 or above 100.

Here are my additional instructions:

Do not use menu bars...Instead add buttons to read the data, save the file after the data has been updated, and exit. The button to calculate the averages should also be coded.
The initial file containing the student scores is StudentData.txt. Code this file with a location of C:\.
Add comments at the top of your code file for your name and the date. Include other comments as appropriate based on the examples in the textbook.
All controls (user interface objects on your form must have meaningful names with appropriate prefixes (for example, btnExit for an exit button).





Here is my code so far. I have been at this for 12 hours to no avail and I have hit a wall and dont know what I am doing wrong. I am novice at best and the course I am in is really rocking me...

Please help!

Here is my form:
Attached Image

Here is my code:

Imports System.IO


Public Class Form1


    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        ' Close(program)
        Me.Close()
    End Sub


    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        StudentScoreDataInput()
    End Sub

End Class

Module StudentTestScoresModule

    Const intMAX_SUBSCRIPT_STUDENT As Integer = 6
    Const intMAX_SUBSCRIPT_STUDENT_SCORES As Integer = 5


    'create structure

    Public Structure StudentData
        Dim strName As String
        Dim dblTestScoresArray() As Double
        Dim dblAverage As Double
    End Structure


    Dim dblScore As Double

    Dim StudentsArray(intMAX_SUBSCRIPT_STUDENT) As StudentData

    Sub StudentNameDataInput()
        StudentsArray(0).strName = Form1.txtName1.Text
        StudentsArray(1).strName = Form1.txtName2.Text
        StudentsArray(2).strName = Form1.txtName3.Text
        StudentsArray(3).strName = Form1.txtName4.Text
        StudentsArray(4).strName = Form1.txtName5.Text
        StudentsArray(5).strName = Form1.txtName6.Text
    End Sub

    Sub StudentScoreDataInput()
       


        For intIndex = 0 To intMAX_SUBSCRIPT_STUDENT
            ReDim StudentsArray(intIndex).dblTestScoresArray(4)
        Next

        'initialize test scores for first student in the array
        StudentsArray(0).dblTestScoresArray(0) = CDbl(Form1.txtS11.Text)
        StudentsArray(0).dblTestScoresArray(1) = CDbl(Form1.txtS12.Text)
        StudentsArray(0).dblTestScoresArray(2) = CDbl(Form1.txtS13.Text)
        StudentsArray(0).dblTestScoresArray(3) = CDbl(Form1.txtS14.Text)
        StudentsArray(0).dblTestScoresArray(4) = CDbl(Form1.txtS15.Text)

        'initialize test scores for second student in the array
        StudentsArray(1).dblTestScoresArray(0) = CDbl(Form1.txtS21.Text)
        StudentsArray(1).dblTestScoresArray(1) = CDbl(Form1.txtS22.Text)
        StudentsArray(1).dblTestScoresArray(2) = CDbl(Form1.txtS23.Text)
        StudentsArray(1).dblTestScoresArray(3) = CDbl(Form1.txtS24.Text)
        StudentsArray(1).dblTestScoresArray(4) = CDbl(Form1.txtS25.Text)

        'initialize test scores for third student in the array
        StudentsArray(2).dblTestScoresArray(0) = CDbl(Form1.txtS31.Text)
        StudentsArray(2).dblTestScoresArray(1) = CDbl(Form1.txtS32.Text)
        StudentsArray(2).dblTestScoresArray(2) = CDbl(Form1.txtS33.Text)
        StudentsArray(2).dblTestScoresArray(3) = CDbl(Form1.txtS34.Text)
        StudentsArray(2).dblTestScoresArray(4) = CDbl(Form1.txtS35.Text)

        'initialize test scores for fourth student in the array
        StudentsArray(3).dblTestScoresArray(0) = CDbl(Form1.txtS41.Text)
        StudentsArray(3).dblTestScoresArray(1) = CDbl(Form1.txtS42.Text)
        StudentsArray(3).dblTestScoresArray(2) = CDbl(Form1.txtS43.Text)
        StudentsArray(3).dblTestScoresArray(3) = CDbl(Form1.txtS44.Text)
        StudentsArray(3).dblTestScoresArray(4) = CDbl(Form1.txtS45.Text)

        'initialize test scores for fifth student in the array
        StudentsArray(4).dblTestScoresArray(0) = CDbl(Form1.txtS51.Text)
        StudentsArray(4).dblTestScoresArray(1) = CDbl(Form1.txtS52.Text)
        StudentsArray(4).dblTestScoresArray(2) = CDbl(Form1.txtS53.Text)
        StudentsArray(4).dblTestScoresArray(3) = CDbl(Form1.txtS54.Text)
        StudentsArray(4).dblTestScoresArray(4) = CDbl(Form1.txtS55.Text)

        'initialize test scores for sixth student in the array
        StudentsArray(5).dblTestScoresArray(0) = CDbl(Form1.txtS61.Text)
        StudentsArray(5).dblTestScoresArray(1) = CDbl(Form1.txtS62.Text)
        StudentsArray(5).dblTestScoresArray(2) = CDbl(Form1.txtS63.Text)
        StudentsArray(5).dblTestScoresArray(3) = CDbl(Form1.txtS64.Text)
        StudentsArray(5).dblTestScoresArray(4) = CDbl(Form1.txtS65.Text)


        Dim intList1 As New List(Of Integer)
        Dim intList2 As New List(Of Integer)
        Dim intList3 As New List(Of Integer)
        Dim intList4 As New List(Of Integer)
        Dim intList5 As New List(Of Integer)
        Dim intList6 As New List(Of Integer)

        ' First Student Average

        intList1.AddRange(New Integer() {CInt(Form1.txtS11.Text), CInt(Form1.txtS12.Text), CInt(Form1.txtS13.Text), CInt(Form1.txtS14.Text), CInt(Form1.txtS15.Text)})

        Form1.lblAvg1.Text = intList1.Average.ToString

        ' Second Student Average

        intList2.AddRange(New Integer() {CInt(Form1.txtS21.Text), CInt(Form1.txtS22.Text), CInt(Form1.txtS23.Text), CInt(Form1.txtS24.Text), CInt(Form1.txtS25.Text)})

        Form1.lblAvg2.Text = intList2.Average.ToString

        ' Third Student Average

        intList2.AddRange(New Integer() {CInt(Form1.txtS31.Text), CInt(Form1.txtS32.Text), CInt(Form1.txtS33.Text), CInt(Form1.txtS34.Text), CInt(Form1.txtS35.Text)})

        Form1.lblAvg3.Text = intList3.Average.ToString

        ' Fourth Student Average

        intList2.AddRange(New Integer() {CInt(Form1.txtS41.Text), CInt(Form1.txtS42.Text), CInt(Form1.txtS43.Text), CInt(Form1.txtS44.Text), CInt(Form1.txtS45.Text)})

        Form1.lblAvg4.Text = intList4.Average.ToString

        ' Fifth Student Average

        intList2.AddRange(New Integer() {CInt(Form1.txtS51.Text), CInt(Form1.txtS52.Text), CInt(Form1.txtS53.Text), CInt(Form1.txtS54.Text), CInt(Form1.txtS55.Text)})

        Form1.lblAvg5.Text = intList5.Average.ToString

        ' Sixth Student Average

        intList2.AddRange(New Integer() {CInt(Form1.txtS61.Text), CInt(Form1.txtS62.Text), CInt(Form1.txtS63.Text), CInt(Form1.txtS64.Text), CInt(Form1.txtS65.Text)})

        Form1.lblAvg6.Text = intList6.Average.ToString

    End Sub

    Sub CalculateAverage()
    End Sub

End Module


Is This A Good Question/Topic? 0
  • +

Replies To: Student Test Scores Array help

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14771
  • View blog
  • Posts: 59,043
  • Joined: 12-June 08

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:07 AM

Quote

Please help!


Would you be more specific in narrowing down the question? Help, how? Are there errors? If so what is the error text and what line is it happening on? Is the code not working as expect? If so what is it doing and what should it be doing?
Was This Post Helpful? 0
  • +
  • -

#3 Naturalivity   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 12-December 13

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:16 AM

It is not running, it throws this error when i try to run:

(I cant get it to run out of debug mode also)

Attached Image
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14771
  • View blog
  • Posts: 59,043
  • Joined: 12-June 08

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:19 AM

Put a break point there.. what is the value of 'form1.txts31.text'? Is it even a number?

Perhaps try Double.TryParse.
Was This Post Helpful? 0
  • +
  • -

#5 Naturalivity   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 12-December 13

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:25 AM

It should be a number, how do I do what you mentioned above?
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14771
  • View blog
  • Posts: 59,043
  • Joined: 12-June 08

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:26 AM

There's a whole tutorial on debugging 101.
http://www.dreaminco...4249-debugging/
Was This Post Helpful? 0
  • +
  • -

#7 Naturalivity   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 12-December 13

Re: Student Test Scores Array help

Posted 12 December 2013 - 08:32 AM

thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1