Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2010 Visual basic chapter 17 excerise 4 Grade solution need to use If/Elseif sta

ID: 3651228 • Letter: 2

Question

2010 Visual basic chapter 17 excerise 4 Grade solution need to use If/Elseif statement get grade letter

Explanation / Answer

For the btnDisplay_Click event, I had: Dim decTestOne As Decimal Dim decTestTwo As Decimal Dim decTestThree As Decimal Decimal.TryParse(txtTest1.Text, decTestOne) Decimal.TryParse(txtTest2.Text, decTestTwo) Decimal.TryParse(txtTest3.Text, decTestThree) lblGrade.Text = CalculateGrade(decTestOne, decTestTwo, decTestThree) For the private function, I used: Private Function CalculateGrade(ByVal testScore1 As Decimal, ByVal testScore2 As Decimal, ByVal testScore3 As Decimal) As String Dim decAverage As Decimal Dim strGrade As String decAverage = (testScore1 + testScore2 + testScore3) / 3 If decAverage >= 90 Then strGrade = "A" ElseIf decAverage >= 80 And decAverage < 90 Then strGrade = "B" ElseIf decAverage >= 70 And decAverage < 80 Then strGrade = "C" ElseIf decAverage >= 60 And decAverage < 70 Then strGrade = "D" Else strGrade = "F" End If Return strGrade End Function I'm not sure if this is the most effective route, but I used it and the solution worked just fine. Let me know if this helped at all or if you need help understanding it. :)