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

Public Class Form1 \'Declare constants for application Const decOilCharge As Dec

ID: 3566262 • Letter: P

Question

Public Class Form1
'Declare constants for application
Const decOilCharge As Decimal = 26D
Const decLubeJob As Decimal = 18D
Const decRadiatorFlush As Decimal = 30D
Const decTransmissionFlush As Decimal = 80D
Const decInspection As Decimal = 15D
Const decMufflerReplacement As Decimal = 100D
Const decTireRotation As Decimal = 20D
Dim decServicesAndLabor As Decimal = 0D
Dim decParts As Decimal = 0D

'Clears check boxes that are on the oil and lube group box
Sub ClearOilLube()
chkOilChange.Checked = False
chkLubeJob.Checked = False

End Sub
'Clears the check boxes that are in the flushes group box
Sub ClearFlushes()
chkRadiator.Checked = False
chkTransmissionFlush.Checked = False

End Sub
'Clears the check boxes that are in the misc group
Sub ClearMisc()
chkInspection.Checked = False
chkReplaceMuffler.Checked = False
chkTireRotation.Checked = False
End Sub
'Clears the fields of parts and labor groups
Sub ClearOther()
txtParts.Text = String.Empty
txtLabor.Text = String.Empty
End Sub
'Clears all the fields of the summary group box
Sub ClearFees()
txtServicesLabor.Text = String.Empty
txtSummaryParts.Text = String.Empty
txtTaxSummary.Text = String.Empty
txtTotalFees.Text = String.Empty
End Sub
'Checked for integer values entered in the textboxes
Function isInputValid() As Boolean
If txtParts.Text <> "" Then
decParts = CDec(CDbl(txtParts.Text))
End If
If txtLabor.Text <> "" Then
decServicesAndLabor = CDec(txtLabor.Text)
End If
If decServicesAndLabor < 0 Or decParts < 0 Then
Return False
End If
Return True
End Function


Private Sub btnCalculateTotal_Click(sender As Object, e As EventArgs) Handles btnCalculateTotal.Click
If isInputValid() Then
Dim decTax As Decimal = 0D
Dim decTotalFees As Decimal = 0D
'Calculates all the charges
decServicesAndLabor += OilLubeCharges() + FlushCharges() + MiscCharges()
decTax = TaxCharges()
decTotalFees = TotalCharges()
'Displays the calculated charges in the textboxes
txtServicesLabor.Text = decServicesAndLabor.ToString("c")
txtSummaryParts.Text = decParts.ToString("c")
txtTaxSummary.Text = decTax.ToString("c")
txtTotalFees.Text = decTotalFees.ToString("c")
Else

'If given input is not valid, then it will display an error message
MessageBox.Show("Don't enter negative values for parts and labor!")
End If


End Sub
'Calculates and returns oil lube charges
Function OilLubeCharges() As Decimal
Dim decOilCharges As Decimal = 0D
If chkOilChange.Checked = True Then
decOilCharges = decOilCharge
End If
If chkLubeJob.Checked = True Then
decOilCharges += decLubeJob

End If
Return decOilCharges


End Function
'Calculates and returns flush charges
Function FlushCharges() As Decimal
Dim decFlushCharges As Decimal = 0D
If chkRadiator.Checked = True Then
decFlushCharges = decRadiatorFlush
End If
If chkTransmissionFlush.Checked = True Then
decFlushCharges += decTransmissionFlush

End If

Return decFlushCharges
End Function

'Calculates and returns misc charges
Function MiscCharges() As Decimal
Dim decMiscCharges As Decimal = 0D
If chkInspection.Checked = True Then
decMiscCharges = decInspection

End If

If chkReplaceMuffler.Checked = True Then
decMiscCharges += decMufflerReplacement
End If
If chkTireRotation.Checked = True Then
decMiscCharges += decTireRotation

End If

Return decMiscCharges
End Function
'Calculates and returns other charges
Function OtherCharges() As Decimal
Dim decOtherCharges As Decimal = 0D
If Not txtParts.Text = "" Then
decOtherCharges = CDec(txtParts.Text)
End If
If Not txtLabor.Text = "" Then
decOtherCharges += CDec(txtLabor.Text)
End If
Return decOtherCharges
End Function

'Calculates and returns tax
Function TaxCharges() As Decimal
If Not txtParts.Text = "" Then
Return CDec(txtParts.Text) * 0.06D

End If
Return 0D
End Function
'Calculates Total Charges
Function TotalCharges() As Decimal
Dim decTotalCharges As Decimal = 0D
decTotalCharges = OilLubeCharges() + FlushCharges() + MiscCharges() + OtherCharges() + TaxCharges()
Return decTotalCharges
End Function


Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub


Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
ClearOilLube()
ClearFlushes()
ClearMisc()
ClearOther()
ClearFees()

End Sub
End Class

Explanation / Answer

Please check the below code which is bolded to clear the text information.

//changed code

'Clears check boxes that are on the oil and lube group box

    Sub ClearOilLube()

        chkOilChange.Checked = ""

        chkLubeJob.Checked = ""

    End Sub

    'Clears the check boxes that are in the flushes group box

    Sub ClearFlushes()

        chkRadiator.Checked = ""

        chkTransmissionFlush.Checked = ""

    End Sub

    'Clears the check boxes that are in the misc group

    Sub ClearMisc()

        chkInspection.Checked = ""

        chkReplaceMuffler.Checked = ""

        chkTireRotation.Checked = ""

    End Sub

    'Clears the fields of parts and labor groups

    Sub ClearOther()

        txtParts.Text = ""

        txtLabor.Text = ""

    End Sub

    'Clears all the fields of the summary group box

    Sub ClearFees()

        txtServicesLabor.Text = ""

        txtSummaryParts.Text = ""

        txtTaxSummary.Text = ""

        txtTotalFees.Text = ""

    End Sub

Note:

1. So far, to clear the text int the text fields data, then it should be presented with double quotes(" "). This will clear up the data.

2. If you are displaying the cost in the same text box where, the input text box for the number of hours is inputed.

Then the calculated number of hours with labour cost should should be modified the text box field. that is,

txtLabor.Text = CDec(txtLabor.Text)*20.00.

3. While clearing all the values, check that all the text input values are initialised to either zero or "".

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote