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

This program should be written in Visual Basic. The TG Automotive repair company

ID: 3816902 • Letter: T

Question

This program should be written in Visual Basic. The TG Automotive repair company performs the following routine maintenance services on passenger automobiles: Oil change - $36.00 Lube job – $28.00 Radiator flush - $50.00 Transmission flush – $120.00 Inspection - $15.00 Muffler replacement - $200.00 Tire rotation - $20.00 TG Automotive also performs other nonroutine services and charges for parts and labor ($60 per hour). Create an application that displays the total for a customer’s visit to the shop. A sample user interface for the application appears in Figure 6-27. Your source code shoud contain functions, such as the ones listed here, that validate inputs and calculate the various parts of the bill: ‘Verify that the two input values are valid ‘numbers and neither is less than zero. Function ValidateInputs() As Boolean ‘Calculate all oil and lubrication charges. Function CalcOilLubeCharges() As Decimal ‘Calculate radiator and transmission flush charges. Function CalcFlushCharges() As Decimal ‘Calculate inspection, muffler, and tire ‘rotation charges. Function CalcMiscCharges() As Decimal ‘Calculate and display the total of all charges, ‘including labor, parts, and services. Sub CalculateTotalCharges() Also, create procedures, such as the ones listed here, that are called when the user clicks the Clear button: ‘Reset the oil change and lube job check boxes. Sub ClearOilLube() ‘Clear the inspection, muffler replacement, and tire ‘rotation check boxes. SubClearMisc() ‘Clear the parts and labor check boxes. Sub ClearOther()

Explanation / Answer

Public Class Form1

    'Declare constants for the program
    Const decOIL_CHANGE As Decimal = 36D
    Const decLUBE_JOB As Decimal = 28D
    Const decINSPECTION As Decimal = 50D
    Const decREPLACE_MUFFLER As Decimal = 120D
    Const decTIRE_ROTATION As Decimal = 15D
    Const decRADIATOR_FLUSH As Decimal = 200D
    Const decTRANSMISSION_FLUSH As Decimal = 20D
    Const decTAX_RATE As Decimal = 60D

    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Misc Services Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function MiscCharges() As Decimal

        'This function returns the cost of misc services
        'as checked in the "Misc" group box.
        Dim decMisc As Decimal = 0D

        If chkInspection.Checked = True Then
            decMisc += decINSPECTION
        End If
        If chkMuffler.Checked = True Then
            decMisc += decREPLACE_MUFFLER
        End If
        If chkTireRotation.Checked = True Then
            decMisc += decTIRE_ROTATION
        End If
        Return decMisc
    End Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Oil and Lube Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function OilLubeCharges() As Decimal

        'This function returns the cost of oil and
        'lube services as checked in the "Oil & Lube"
        'group box.
        Dim decOilAndLube As Decimal = 0D

        If chkOilChange.Checked = True Then
            decOilAndLube += decOIL_CHANGE
        End If

        If chkLubeJob.Checked = True Then
            decOilAndLube += decLUBE_JOB
        End If

        Return decOilAndLube
    End Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Flushes Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function FlushCharges() As Decimal

        'This function returns the cost of flush
        'services as checked in the "Flushes"
        'group box.
        Dim decFlushes As Decimal = 0D

        If chkRadiatorFlush.Checked = True Then
            decFlushes += decRADIATOR_FLUSH
        End If
        If chkTransmissionFlush.Checked = True Then
            decFlushes += decTRANSMISSION_FLUSH
        End If

        Return decFlushes
    End Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Validate Parts Input Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function GetParts(
    ByRef decAdditionalParts As Decimal) As Boolean

        Dim blnValid As Boolean

        blnValid = Decimal.TryParse(txtAddParts.Text, decAdditionalParts)

        If blnValid = False Then
            MessageBox.Show("Please enter a dollar amount for Parts.")
            With txtAddParts
                .SelectAll()
                .Focus()
            End With
        End If
        If decAdditionalParts < 0 Then
            MessageBox.Show("Please enter a positive value for" &
                            " the parts cost.")
        End If
        Return blnValid

    End Function

    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Validate Labor Input Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function GetLabor(
    ByRef decAdditionalLabor As Decimal) As Boolean

        Dim blnValid As Boolean

        blnValid = Decimal.TryParse(txtAddLabor.Text, decAdditionalLabor)

        If blnValid = False Then
            MessageBox.Show("Please enter a dollar" &
                            " amount for Labor cost.")
            With txtAddLabor
                .SelectAll()
                .Focus()
            End With
        End If
        If decAdditionalLabor < 0 Then
            MessageBox.Show("Please enter a positive value for" &
                            " the labor cost.")
        End If
        Return blnValid

    End Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Tax Calculation Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Function CalcTax(ByVal decAmount As Decimal) As Decimal

        ' this function receives the parts amount. It

        ' calculates and returns the parts tax, based

        ' on the parts amount.
        Dim decPartsCost As Decimal


        If txtAddParts.Text = String.Empty Then
            Return 0
        Else

            decPartsCost = CDec(txtAddParts.Text)

            Return decPartsCost * decTAX_RATE
        End If
    End Function
    '"""""""""""""""""""""""""""""""""""""""""""""""
    'Calculation Button
    '"""""""""""""""""""""""""""""""""""""""""""""""
    Private Sub btnCalculate_Click(
    ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles btnCalculate.Click

        ' Calculate the total cost of services.
        Dim decServiceAndLabor As Decimal ' Holds the labor and services total
        Dim decAddParts As Decimal        ' Holds the parts order
        Dim decAddLabor As Decimal        ' Holds the labor fees
        Dim decTax As Decimal             ' holds the tax on parts
        Dim decTotal As Decimal           ' holds the order total

     
''''' BELOW IS WHERE I AM HAVING THE PROBLEM RIGHT NOW'''''''''''

        'Call on "GetParts" function and "GetLabor" function to
        'check the data entered into the 'text boxes.

        If GetParts(decAdditionalParts) = False Then
            Return
        End If

        If GetLabor(decAdditionalLabor) = False Then
            Return
        End If

        decAddLabor = CDec(txtAddLabor.Text)

        'Get the cost of services and labor
        decServiceAndLabor = FlushCharges() + OilLubeCharges() +
         MiscCharges() + decAddLabor

        decAddParts = CDec(GetParts())

        decTax = CalcTax(decAddParts)

        ' Calculate the total...
        decTotal = decServiceAndLabor + decAddParts + decTax

        ' Display the results...

        txtServiceAndLabor.Text = decServiceAndLabor.ToString("c")
        txtPartsPrice.Text = decAddParts.ToString("c")
        txtTaxOnParts.Text = decTax.ToString("c")
        txtTotalFees.Text = decTotal.ToString("c")
    End Sub

End Class

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