Suppose a teacher has five students who have taken four tests. The teacher uses
ID: 3632043 • Letter: S
Question
Suppose a teacher has five students who have taken four tests. The teacher uses the standard grading scale to issue students grades based of their avereage of the 4 test scores (90-100% =A, etc.)Create an application that uses an array of strings to hold the five students names, an array of five strings to hold each students letter grades, and five arrays of four single precision numbers to hold each students set of test scores.
Must: Display a form that allows the user to enter or change the student names and test scores
Calculate and display each students average test score and a letter grade based on the average.
Do not accept scores less than 0 or greater than 100
Modify the app so it drops the students lowest score when determining the average.
Explanation / Answer
Dear... The 7PC of chapter 8 can we viewed in the text book help in the link: http://www.cramster.com/solution/solution/1215603 And for 8PC, The solution is almost similar to 7PC only the function getAverage() is modified, so it drops the students lowest score when determining the average. The form design is Exactly same as 7PC form, so i would suggest to see the solution from above link and design the form and follow the steps. The Code : Public Class Form1 Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click Dim studentNames(4) As String Dim Grades(4) As String Dim Student1Scores(3) As Integer Dim Student2Scores(3) As Integer Dim Student3Scores(3) As Integer Dim Student4Scores(3) As Integer Dim Student5Scores(3) As Integer Dim intCount As Integer = 0 Dim StudentAVG(4) As Double lstGrades.Items.Clear() Try studentNames(0) = txtStudent1.Text studentNames(1) = txtStudent2.Text studentNames(2) = txtStudent3.Text studentNames(3) = txtStudent4.Text studentNames(4) = txtStudent5.Text Student1Scores(0) = IsValid(CInt(txtOneScore1.Text)) Student1Scores(1) = IsValid(CInt(txtOneScore2.Text)) Student1Scores(2) = IsValid(CInt(txtOneScore3.Text)) Student1Scores(3) = IsValid(CInt(txtOneScore4.Text)) Student2Scores(0) = IsValid(CInt(txtTwoScore1.Text)) Student2Scores(1) = IsValid(CInt(txtTwoScore2.Text)) Student2Scores(2) = IsValid(CInt(txtTwoScore3.Text)) Student2Scores(3) = IsValid(CInt(txtTwoScore4.Text)) Student3Scores(0) = IsValid(CInt(txtThreeScore1.Text)) Student3Scores(1) = IsValid(CInt(txtThreeScore2.Text)) Student3Scores(2) = IsValid(CInt(txtThreeScore3.Text)) Student3Scores(3) = IsValid(CInt(txtThreeScore4.Text)) Student4Scores(0) = IsValid(CInt(txtFourScore1.Text)) Student4Scores(1) = IsValid(CInt(txtFourScore2.Text)) Student4Scores(2) = IsValid(CInt(txtFourScore3.Text)) Student4Scores(3) = IsValid(CInt(txtFourScore4.Text)) Student5Scores(0) = IsValid(CInt(txtFiveScore1.Text)) Student5Scores(1) = IsValid(CInt(txtFiveScore2.Text)) Student5Scores(2) = IsValid(CInt(txtFiveScore3.Text)) Student5Scores(3) = IsValid(CInt(txtFiveScore4.Text)) StudentAVG(0) = getAverage(Student1Scores) StudentAVG(1) = getAverage(Student2Scores) StudentAVG(2) = getAverage(Student3Scores) StudentAVG(3) = getAverage(Student4Scores) StudentAVG(4) = getAverage(Student5Scores) For intCount = 0 To 4 If StudentAVG(intCount) >= 90 Then Grades(intCount) = "A" ElseIf StudentAVG(intCount) >= 80 Then Grades(intCount) = "B" ElseIf StudentAVG(intCount) >= 70 Then Grades(intCount) = "C" ElseIf StudentAVG(intCount) >= 60 Then Grades(intCount) = "D" ElseIf StudentAVG(intCount) > 0 Then Grades(intCount) = "F" End If Next For intCount = 0 To 4 lstGrades.Items.Add(" Average Score for " & studentNames(intCount) & " is " & StudentAVG(intCount) & " his Grade is " & Grades(intCount)) Next Catch MessageBox.Show("Invalid Input: Enter Values between(0-100)", "Error") End Try End Sub Public Function getAverage(ByVal StudentScores() As Integer) Dim intTotal, intCount As Integer Dim dblAverage As Double Array.Sort(StudentScores) 'sorts the array in asscending order For intCount = 1 To 3 'eliminating the first value in the array which is nothing but the lowest score intTotal += StudentScores(intCount) Next dblAverage = intTotal / 3 Return dblAverage End Function Public Function IsValid(ByVal intNum As Integer) If intNum > 0 And intNumRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.