I am trying to do the Student Test Scores problem (#3, page 593) CHAPTER 9 in St
ID: 3855630 • Letter: I
Question
I am trying to do the Student Test Scores problem (#3, page 593) CHAPTER 9 in Starting Out with Visual Basic 2012. There is a solution posted, butI cannot use it because in step 6 of the solution it uses: Imports System.IO.FileStream (line2), Class name MyStudentTestScores (Line 3), Public ClassMyStudentTestScores (line 4), etc Because we have not gotten to this type of code in the class yet. Is there a solution that does not use this type of code. We were just introduced to the Imports System.IO in this lesson. We have not been introduced to class yet. If you can help, I would greatly appreciate it. Thanks How do I do this?
Explanation / Answer
//Try this code, it will help you 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 dblTotalStd1 As Double Dim dblTotalStd2 As Double Dim dblTotalStd3 As Double Dim dblTotalStd4 As Double Dim dblTotalStd5 As Double Dim dblTotalStd6 As Double 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() Dim dblAverage As Double 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(1).dblTestScoresArray(1) = CDbl(Form1.txtS12.Text) StudentsArray(2).dblTestScoresArray(2) = CDbl(Form1.txtS13.Text) StudentsArray(3).dblTestScoresArray(3) = CDbl(Form1.txtS14.Text) StudentsArray(4).dblTestScoresArray(4) = CDbl(Form1.txtS15.Text) For Each i As StudentData In StudentsArray For Each S As Double In i.dblTestScoresArray dblTotalStd1 += S Next Next dblAverage = dblTotalStd1 / intMAX_SUBSCRIPT_STUDENT_SCORES Form1.lblAvg1.Text = (dblAverage.ToString) End Sub Sub CalculateAverage() End Sub End Module
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.