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

Fix the code debugging exercises chapter 7. I did the first two but want to make

ID: 3698083 • Letter: F

Question

Fix the code debugging exercises chapter 7. I did the first two but want to make sure I made no mistakes. Number 3 I haven't solved.

1) Private Sub btnItemNumber_Click (By Val sender As System.Object, ByVal e As System.EventArgs) Handles btnItemNumber.Click
         Dim decCost as Decimal
         Dim intCount As Decimal = 0


decCost = Convert.ToDecimal(txtCost.Text)
Inventory(decCost, intCount)

End Sub

Private Sub Inventory (ByVal cost as Decimal, ByVal count as Decimal)
Count +=3
Cost *=1.3
End Sub

2) Private Sub btnBaseball_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaseball.Click

Dim decHits As Decimal = 190

Dim decTimesAtBat As Decimal = 428

Dim decBattingAverage As Decimal

decBattingAverage = FindBattingAverage (decHits, decTimesAtBat)

lblHits.txt ("The batting avaerage is ") & decBattingAverage

End Sub

Private Function BattingAverage (ByVal decHitsCount as Decimal. ByVal decNumberAtBat as Decima) As Decimal

Dim decAverageAtBat as Decimal

decAverage = decHitsCount decNumberAtBat

Return decAverage

End Function

3) Private sub btnMileage_Click (ByVal sender As System.Object, ByVal e As System.Event Args) Handles btnMileage.Click

Dim decMiles As Decimal = 350D

Dim decGallons As Decimal = 12.8D

Dim decMilesPer As Decimal

decMilesPer = Compute (decMiles, decGallons)

lblDisplays.Text = "Your MPG" is " & decMilesToString()

Private Sub Compute (ByVal decM As Decimal, ByVal decG) As Decimal

Dim decMPG As Decimal

decMPG = decM / decG

Return MPG

End Function.

Explanation / Answer

For Q1. I think its incomplete. I am not sure what txtCost.Text is. I have solved the other two :)

Q3.

Private sub btnMileage_Click (ByVal sender As System.Object, ByVal e As System.Event Args) Handles btnMileage.Click
Dim decMiles As Decimal = 350D
Dim decGallons As Decimal = 12.8D
Dim decMilesPer As Decimal
decMilesPer = Compute (decMiles, decGallons)
lblDisplays.Text = "Your MPG" is " & decMilesToString()
Private Sub Compute (ByVal decM As Decimal, ByVal decG) As Decimal
Dim decMPG As Decimal
decMPG = decM / decG
Return MPG       // It will be return decMPG
End Function.

And the answer will be: "Your MPG is 27.34"

Q2.
Private Sub btnBaseball_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaseball.Click
Dim decHits As Decimal = 190
Dim decTimesAtBat As Decimal = 428
Dim decBattingAverage As Decimal
decBattingAverage = FindBattingAverage (decHits, decTimesAtBat)
lblHits.txt ("The batting avaerage is ") & decBattingAverage
End Sub
Private Function BattingAverage (ByVal decHitsCount as Decimal. ByVal decNumberAtBat as Decima) As Decimal
Dim decAverageAtBat as Decimal
decAverage = decHitsCount decNumberAtBat               // HEre it will be division sign like this "/"
Return decAverage
End Function

And the answer will be: "The batting avaerage is 0.44"

Q1.

Private Sub btnItemNumber_Click (By Val sender As System.Object, ByVal e As System.EventArgs) Handles btnItemNumber.Click
Dim decCost as Decimal
Dim intCount As Decimal = 0

decCost = Convert.ToDecimal(txtCost.Text)
Inventory(decCost, intCount)

End Sub
Private Sub Inventory (ByVal cost as Decimal, ByVal count as Decimal)
Count +=3
Cost *=1.3
End Sub