1 Replies - 4687 Views - Last Post: 20 May 2010 - 02:47 AM Rate Topic: -----

#1 d3vil112  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 2
  • Joined: 14-May 10

final exam grade statistic

Posted 14 May 2010 - 09:23 PM

Create a text file, “Final.txt” that contains 25 student grades on a final exam:
78,85,50,93,88,97,55,72,81,90,80,46,77,86,66,72,65,83,90,77,81,78,50,53,87

Then write a program that reads the grades from the file and displays the number of scores in the

(1) “A” range (90-100)
(2) “B” range (80-89)
(3) “C” range (70-79)
(4) “D” range (60-69)
(5) “F” range (below 60)

Also list the highest score, lowest score, the average (mean) score and the percentage of the grades that fall above the average.
You must use a Do loop to read the file and count the number of grades.
You must use a case statement to count how many grades are in each range.
The number of grades should be stored as a variable and used in the calculation of the Average
High Score, Low score, Average and % above average must be figured out within the program.

Hints:
1) You can not figure out the average until after you have read in all of the test scores.
2) After figuring out the average you must read the file in another loop to figure out how many are above average
3) For low score & High score you must compare the current score to the hig/low score so far. In order for this to work, High score must start out being the lowest score possible (0) and the variable for low score must start out being the highest score possible (100).

Do not use more than 2 loops.

i did most of the part..but still stuck with the loop

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnd.Click
        MessageBox.Show("night")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
        txtA.Clear()
        txtB.Clear()
        txtC.Clear()
        txtD.Clear()
        txtF.Clear()
        txtHs.Clear()
        txtls.Clear()
        txtAvearge.Clear()
        txtofGrades.Clear()



    End Sub

    Private Sub BtnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisplay.Click
        Dim ACount As Integer
        Dim bcount As Integer
        Dim Ccount As Integer
        Dim dcount As Integer
        Dim fcount As Integer
        Dim i As Integer
        Dim grade(25) As Double
        Dim y As Integer
        Dim average As Double
        Dim Number(Me.txtAvearge.Item.Count - 1) As Double
        Dim lowergrade, highergrade As Double
        Dim newarray As String


        For y = 0 To (Me.txtAvearge.item.count - 1)
            Number(y) = CDbl(display.Items.Item(y))


        Next y
        Array.Sort(Number)
        For y = 0 To y
            newarray = newarray & Convert.ToString(Number(y) & "")

        Next y
        lowergrade = Number(0)
        highergrade = Number(Number.Length - 1)


        Dim sr As IO.StreamReader = IO.File.OpenText("C:\Users\Stephen Ficarola\Desktop\LabPrjct5\LabPrjct5\final.txt")

        Do Until sr.Peek = -1
            grade(i) = sr.ReadLine

            If grade(i) >= 90 Then
                ACount = ACount + 1

            ElseIf grade(i) >= 80 Then
                bcount = bcount + 1
            ElseIf grade(i) >= 70 Then
                Ccount = Ccount + 1
            ElseIf grade(i) >= 60 Then
                dcount = dcount + 1
            ElseIf grade(i) <= 59 Then
                fcount = fcount + 1

            End If

        Loop
        sr.Close()
        For i As Integer = 0 To grade.GetUpperBound(0)
        Next
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
thx in advance...

Attached File(s)



Is This A Good Question/Topic? -1
  • +

Replies To: final exam grade statistic

#2 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: final exam grade statistic

Posted 20 May 2010 - 02:47 AM

Hi

can you explain why you want to do this?

 For y = 0 To y


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1