I\'m having trouble with the Visual Basic problem below. I have written the code
ID: 3631822 • Letter: I
Question
I'm having trouble with the Visual Basic problem below. I have written the code for it and cannot figure out what is wrong with my code. I have listed the problem as well as the code I've written. Please help me figure out what I'm doing wrong.
Joe's Automotive performs the following routine maintenance services:
Oil change- $26.00
Lube job - $18.00
Radiator flush - $30.00
Transmission flush - $80.00
Inspection - $15.00
Muffer replacement - $100.00
Tire rotation - $20.00
Joe also performs other non routine services and charges for parts and labor ($20 per hour). Create an application that displays the total for a customers visit to Joes . All amounts are decimal.The form should look like the one shown below.
Include these functions:
OilLubeCharges: returns the total charges for an oil change and/or lube job, if any.
FlushCharges: returns the total charges for a radiator flush and/or transmission flush, if any.
MiscCharges Returns the total charges for an inspection, muffler replacement, and/or a tire rotation, if any.
OtherCharges returns the total charges for other services (parts and labor), if any. Note- add the labor rate as a parameter.
TaxCharges: Returns the amount of sales tax, if any. Sales tax is 6%, and is only charged on parts. If the customer purchased services only, no sales tax is charged.
Total Charges: Returns the total charges
Here is the code I have written:
Public Class Form1
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim OilChange, LubeJob, RadiatorFlush, TransmissionFlush, Inspection, ReplaceMuffler, TireRotation As Decimal
Dim Parts, Labor, TotOilLube, TotFlush, TotMisc, TotPartLabor, TotTax, Total As Decimal
Parts = CDec(txtParts.Text)
Labor = CDec(txtLabor.Text)
If chkOilChange.Checked Then
OilChange = 26D
ElseIf chkLubeJob.Checked Then
LubeJob = 18D
ElseIf chkRadiatorFlush.Checked Then
RadiatorFlush = 30D
ElseIf chkTransmissionFlush.Checked Then
TransmissionFlush = 80D
ElseIf chkInspection.Checked Then
Inspection = 15D
ElseIf chkReplaceMuffler.Checked Then
ReplaceMuffler = 100D
ElseIf chkTireRotation.Checked Then
TireRotation = 20D
End If
TotOilLube = OilLubeCharges(OilChange, LubeJob)
TotFlush = FlushCharges(RadiatorFlush, TransmissionFlush)
TotMisc = MiscCharges(Inspection, ReplaceMuffler, TireRotation)
TotPartLabor = OtherCharges(Parts, Labor)
TotTax = TaxCharges(Parts)
Total = TotalCharges()
lblTotOilLube.Text = TotOilLube.ToString("c")
lblTotFlushes.Text = TotFlush.ToString("c")
lblTotMisc.Text = TotMisc.ToString("c")
lblTotPartsLabor.Text = TotPartLabor.ToString("c")
lblTaxParts.Text = TotTax.ToString("c")
End Sub
Public Function OilLubeCharges(ByVal OilChange As Decimal, ByVal LubeJob As Decimal)
Return OilChange + LubeJob
End Function
Public Function FlushCharges(ByVal RadiatorFlush As Decimal, ByVal TransmissionFlush As Decimal)
Return RadiatorFlush + TransmissionFlush
End Function
Public Function MiscCharges(ByVal Inspection As Decimal, ByVal ReplaceMuffler As Decimal, ByVal TireRotation As Decimal)
Return Inspection + ReplaceMuffler + TireRotation
End Function
Public Function OtherCharges(ByVal Parts As Decimal, ByVal Labor As Decimal)
Return Parts + Labor
End Function
Public Function TaxCharges(ByVal Parts As Decimal)
Return CDec(txtParts.Text) * 0.06D
End Function
Public Function TotalCharges(ByVal OilLubeCharges As Decimal, ByRef FlushCharges As Decimal, ByVal MiscCharges As Decimal, ByVal OtherCharges As Decimal, ByVal TaxCharges As Decimal)
Return OilLubeCharges + FlushCharges + MiscCharges + OtherCharges + TaxCharges
End Function
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
chkOilChange.Checked = False
chkLubeJob.Checked = False
chkRadiatorFlush.Checked = False
chkTransmissionFlush.Checked = False
chkInspection.Checked = False
chkReplaceMuffler.Checked = False
chkTireRotation.Checked = False
txtParts.Clear()
txtLabor.Clear()
lblTotOilLube.Text = String.Empty
lblTotFlushes.Text = String.Empty
lblTotMisc.Text = String.Empty
lblTotPartsLabor.Text = String.Empty
lblTaxParts.Text = String.Empty
lblTot.Text = String.Empty
End Sub
End Class
Thanks in advance for any help.
Explanation / Answer
Public Class Form1
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim OilChange, LubeJob, RadiatorFlush, TransmissionFlush, Inspection, ReplaceMuffler, TireRotation As Decimal
Dim Parts, Labor, TotOilLube, TotFlush, TotMisc, TotPartLabor, TotTax, Total As Decimal
Parts = CDec(txtParts.Text)
Labor = CDec(txtLabor.Text)
If chkOilChange.Checked Then
OilChange = 26D
End If
If chkLubeJob.Checked Then
LubeJob = 18D
End If
If chkRadiatorFlush.Checked Then
RadiatorFlush = 30D
End If
If ChkTransmissionFlush.Checked Then
TransmissionFlush = 80D
End If
If chkInspection.Checked Then
Inspection = 15D
End If
If chkReplaceMuffler.Checked Then
ReplaceMuffler = 100D
End If
If chkTireRotation.Checked Then
TireRotation = 20D
End If
TotOilLube = OilLubeCharges(OilChange, LubeJob)
TotFlush = FlushCharges(RadiatorFlush, TransmissionFlush)
TotMisc = MiscCharges(Inspection, ReplaceMuffler, TireRotation)
TotPartLabor = OtherCharges(Parts, Labor)
TotTax = TaxCharges(Parts)
Total = TotalCharges(TotOilLube, TotFlush, TotMisc, TotPartLabor, TotTax)
lblTotOil.Text = TotOilLube.ToString("c")
lblTotflushes.Text = TotFlush.ToString("c")
lblMisc.Text = TotMisc.ToString("c")
lbltotalParts.Text = TotPartLabor.ToString("c")
lblTax.Text = TotTax.ToString("c")
lblTotal.Text = Total.ToString("c")
End Sub
Public Function OilLubeCharges(ByVal OilChange As Decimal, ByVal LubeJob As Decimal)
Return OilChange + LubeJob
End Function
Public Function FlushCharges(ByVal RadiatorFlush As Decimal, ByVal TransmissionFlush As Decimal)
Return RadiatorFlush + TransmissionFlush
End Function
Public Function MiscCharges(ByVal Inspection As Decimal, ByVal ReplaceMuffler As Decimal, ByVal TireRotation As Decimal)
Return Inspection + ReplaceMuffler + TireRotation
End Function
Public Function OtherCharges(ByVal Parts As Decimal, ByVal Labor As Decimal)
Return Parts + Labor
End Function
Public Function TaxCharges(ByVal Parts As Decimal)
Return CDec(txtParts.Text) * 0.06D
End Function
Public Function TotalCharges(ByVal TotOilLube As Decimal, ByVal TotFlushes As Decimal, ByVal TotMisc As Decimal, ByVal TotPartsLabor As Decimal, ByVal Tax As Decimal)
Return TotOilLube + TotFlushes + TotMisc + TotPartsLabor + Tax
End Function
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
chkOilChange.Checked = False
chkLubeJob.Checked = False
chkRadiatorFlush.Checked = False
ChkTransmissionFlush.Checked = False
chkInspection.Checked = False
chkReplaceMuffler.Checked = False
chkTireRotation.Checked = False
txtParts.Clear()
txtLabor.Clear()
lblTotOil.Text = String.Empty
lblTotflushes.Text = String.Empty
lblMisc.Text = String.Empty
lbltotalParts.Text = String.Empty
lblTax.Text = String.Empty
lblTotal.Text = String.Empty
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.