hello i need help with the code part of this I have the lay out and some of the
ID: 3629569 • Letter: H
Question
hello i need help with the code part of this I have the lay out and some of the code but its confusing me..
Joes automotive performs the following services
Oil Change $26.00
Lube Job $18.00
Radiator Flush $30.00
Transmission Flush $80.00
Inspection $15.00
Muffler Replacement $100.00
Tire Rotation $20.00
Joe also preforms other services and charges for parts and labor ($20.00 per hour). Create an application that displays the total for a customers visit to Joes.
The application should hav ethe following functions
OilLubeCharges - Returns the t0tal charges for an oil and/or lube job, if any
FlushCharges - returns the total charges for a radiator and/or a transmission flush, if any
MiscCharges - Returns the total charges for an inspection, muffler replacement, and/or tire rotation, if any
OtherCharges - Returns the total charges for other services (parts and labor), if any
TaxCharges - Returns ammount of sales tax, if any. Slaes tax is 6%, and only charged on parts.
input validation: do not accept negative numbers or letters on parts and labor charges
Explanation / Answer
Dear...Public Class Form
Const decTAX_RATE As Decimal = 0.06D
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim decServicesLabor As Decimal
Dim decParts As Decimal ' holds the parts order
Dim decTax As Decimal ' holds the tax on parts
Dim decTotal As Decimal ' holds the order total decServicesLabor = OilLubeCharges() + FlushCharges() + MiscCharges() + OtherCharges()
decParts = PartsCost()
decTax = CalcTax(decParts)
decTotal = decServicesLabor + decTax
lblServicesLabor.Text = decServicesLabor.ToString("c")
lblParts.Text = decParts.ToString("c")
lblTax.Text = decTax.ToString("c")
lblTotal.Text = decTotal.ToString("c")
End Sub
Function PartsIsValid() As Boolean
Dim decTempValue As Decimal
If Not Decimal.TryParse(txtParts.Text, decTempValue) Then
MessageBox.Show("Enter a numeric value for the parts cost.")
Return False
End If
If decTempValue < 0 Then
MessageBox.Show("Enter a positive value for the parts cost.")
End If
Return True
End Function
Function LaborIsValid() As Boolean
Dim decTempValue2 As Decimal
If Not Decimal.TryParse(txtLabor.Text, decTempValue2) Then
MessageBox.Show("Enter a numeric value for the labor cost.")
Return False
End If
If decTempValue2 < 0 Then
MessageBox.Show("Enter a positive value for the labor cost.")
End If Return True
End Function Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click ResetOilLubeCharges()
ResetFlushCharges()
ResetMiscCharges()
txtParts.Text = ""
txtLabor.Text = ""
lblServicesLabor.Text = ""
lblTax.Text = ""
lblParts.Text = ""
lblTotal.Text = ""
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Function OilLubeCharges() As Decimal
Dim decCostOfOilLube As Decimal = 0
If chkOilChange.Checked = True Then
decCostOfOilLube += 26D
End If
If chkLubeJob.Checked = True Then
decCostOfOilLube += 18D
End If
Return decCostOfOilLube
End Function
Function FlushCharges() As Decimal
Dim decCostOfFlush As Decimal = 0
If chkRadiatorFlush.Checked = True Then
decCostOfFlush += 30D
End If
If chkTransmissionFlush.Checked = True Then
decCostOfFlush += 80D
End If
Return decCostOfFlush
End Function
Function MiscCharges() As Decimal
Dim decCostOfMisc As Decimal = 0
If chkInspection.Checked = True Then
decCostOfMisc += 15D
End If
If chkReplaceMuffler.Checked = True Then
decCostOfMisc += 100D
End If
If chkTireRotation.Checked = True Then
decCostOfMisc += 20D
End If
Return decCostOfMisc
End Function
Function PartsCost() As Decimal
End Function
Function OtherCharges() As Decimal
End Function
Function CalcTax(ByVal decAmount As Decimal) As Decimal
Return decAmount * decTAX_RATE
End Function
Private Sub ResetOilLubeCharges()
chkOilChange.Checked = False
chkLubeJob.Checked = False
End Sub
Sub ResetFlushCharges()
chkRadiatorFlush.Checked = False
chkTransmissionFlush.Checked = False
End Sub Sub ResetMiscCharges()
chkInspection.Checked = False
chkReplaceMuffler.Checked = False
chkTireRotation.Checked = False
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.