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

I\'m having trouble with the Visual Basic problem below in C#.. I have written t

ID: 3563274 • Letter: I

Question

I'm having trouble with the Visual Basic problem below in C#.. 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

private void button1_Click(object sender, EventArgs e)
        {

            OilLubeCharges();
            FlushCharges();
            MiscCharges();
            OtherCharges();
            TaxCharges();
            TotalCharges();

        }

        private int OilLubeCharges()

        {
            int total = 0;

           if (oilChangeCheckBox.Checked)
            {
                total += 26;
          //serviceAndLaborOutPutLabel.Text = total.ToString("c");
            }

            //if lube is checked, add 18 to total
            if (lubeCheckBox.Checked)
            {
                total += 18;
                //serviceAndLaborOutPutLabel.Text = total.ToString("c");
                return total;
            }
            else
            {
                return total;
            }
        }


        //method for calculating Flushes
        private int FlushCharges()
        {
            //define local variable
            int total = 0;

            //if radiator is checked, add 30 to total
            if (radiatorFlushCheckBox.Checked)
            {
                total += 30;
                //serviceAndLaborOutPutLabel.Text = total.ToString("c");
            }


            //if transmission is checked, add 80 to total
            if (transmissionCheckBox.Checked)
            {
                total += 80;
                // serviceAndLaborOutPutLabel.Text = total.ToString("c");
                return total;
            }
            else
            {
                return total;
            }
        }


        private int MiscCharges()
        {
            //define local variable
            int total = 0;
            //if inspection is checked, add to total
            if (inspectionCheckBox.Checked)
            {
                total += 15;
                //serviceAndLaborOutPutLabel.Text = total.ToString("c");

            }
            //if replace muffler is checked, add 100 to total
            if (replaceMuffCheckBox.Checked)
            {
                total += 100;
                // serviceAndLaborOutPutLabel.Text = total.ToString("c");

            }
            //if tire rotation is checked, add 20 to total
            if (tireRotateCheckBox.Checked)
            {
                total += 20;
                //serviceAndLaborOutPutLabel.Text = total.ToString("c");
                return total;

            }
            else
            {
                return total;
            }
        }

        private int OtherCharges()
        {
            int total = 0;
            int labor;
              int parts;


            if (int.TryParse(laborCostTextBox.Text, out labor))
            {
                serviceAndLaborOutPutLabel.Text = labor.ToString("c");
                total = labor;

                return total;
            }

             if (int.TryParse(partsTextBox.Text, out parts))
             {
                 partsOutPutLabel.Text = parts.ToString("c");
                 total = parts;
      
                 return total;
             }
            else
            {
                return total;
            }

        }

        private decimal TaxCharges()
        {
            decimal addTax;
            decimal tax = 0;
            decimal parts;
            decimal totalParts = 0;

            if (decimal.TryParse(partsTextBox.Text, out parts))
            {
                totalParts = parts;
                partsOutPutLabel.Text = totalParts.ToString("c");

                if (decimal.TryParse(taxOutPutLabel.Text, out addTax))
                {
                    tax = totalParts * 0.08m;
                    taxOutPutLabel.Text = tax.ToString("c");
                    return tax;
                }
                else
                {
                    return totalParts;
                }

            }
            else
            {
                return tax;
            }
        }

        private decimal TotalCharges()
        {
            decimal total;

            total = OtherCharges() + MiscCharges() + OilLubeCharges() + FlushCharges() + TaxCharges();
            totalOutPutLabel.Text = total.ToString("c");
            return total;

        }               

        private void exitButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonClear_Click(object sender, EventArgs e)
        {
            partsTextBox.Text = "";
            laborCostTextBox.Text = "";
            serviceAndLaborOutPutLabel.Text = "";
            partsOutPutLabel.Text = "";
            taxOutPutLabel.Text = "";
            totalOutPutLabel.Text = "";
            oilChangeCheckBox.Checked = false;
            lubeCheckBox.Checked = false;
            radiatorFlushCheckBox.Checked = false;
            transmissionCheckBox.Checked = false;
            inspectionCheckBox.Checked = false;
            replaceMuffCheckBox.Checked = false;
            tireRotateCheckBox.Checked = false;
        }
    }
}

Explanation / Answer

//This is For the services part
import java.awt.*;
import javax.swing.*;
public class Service extends JPanel
{
public final double OIL_CHANGE = 26.00;
public final double LUBE_JOB = 18.00;
public final double RADIATOR_FLUSH = 30.00;
public final double TRANSMISSION_FLUSH = 80.00;
public final double INSPECTION = 15.00;
public final double MUFFLER_REPLACEMENT = 100.00;
public final double TIRE_ROTATION = 20.00;
private JTextField calcTextField;
private JCheckBox Oil_change;
private JCheckBox Lube_job;
private JCheckBox Radiator_flush;
private JCheckBox Transmission_flush;
private JCheckBox Inspection;
private JCheckBox Muffler_replacement;
private JCheckBox Tire_rotation;
public Service()
{
setLayout(new GridLayout(7,1 ));
Oil_change = new JCheckBox("Oil Change ($26.00)");
Lube_job = new JCheckBox("Lube Job ($18.00)");
Radiator_flush = new JCheckBox("Radiator Flush ($30.00)");
Transmission_flush = new JCheckBox("Transmission Flush ($80.00)");
Inspection = new JCheckBox("Inspection ($50.00)");
Muffler_replacement = new JCheckBox("Muffler Replacement ($100.00)");
Tire_rotation = new JCheckBox("Tire Rotation ($20.00)");
setBorder(BorderFactory.createTitledBo... Services"));
add(Oil_change);
add(Lube_job);
add(Radiator_flush);
add(Transmission_flush);
add(Inspection);
add(Muffler_replacement);
add(Tire_rotation);
public double actionCalculate()
{
double total = 0;
if(Oil_change.isSelected())
total = total + OIL_CHANGE;
if(Lube_job.isSelected())
total = total + LUBE_JOB;
if(Radiator_flush.isSelected())
total = total + RADIATOR_FLUSH ;
if(Transmission_flush.isSelected())
total = total + TRANSMISSION_FLUSH;
if(Inspection.isSelected())
total = total + INSPECTION;
if(Muffler_replacement.isSelected())
total = total + MUFFLER_REPLACEMENT;
if(Tire_rotation.isSelected())
total = total + TIRE_ROTATION;
return total;
}
}
//This for NonRoutine Services
import java.awt.*;
import javax.swing.*;
public class NonService extends JPanel
{
public final double perHourCharge = 20.00; //per hour labor cost
private JLabel partsLabel; //references parts charges label
private JLabel laborLabel; //references hours of labor label
private JTextField partsTextField; //references parts charges text field
private JTextField laborTextField; //references hours of labor text field
private JPanel panel;
public NonService()
{
partsLabel = new JLabel("Parts Charges:");
laborLabel = new JLabel("Hours of Labor:");
partsTextField = new JTextField(10);
laborTextField = new JTextField(10);
setBorder(BorderFactory.createTitledBo... services"));
add(partsLabel);
add(partsTextField);
add(laborLabel);
add(laborTextField);
panel = new JPanel();
panel.setLayout(new GridLayout(3,2));
setLayout(new GridLayout(2, 2));
}
}
// This where I put the calc and exit buttons but it does not show up when I run it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class CalculatorGUI extends JFrame
{
private Service sc;
private NonService ns;
private JPanel buttonPanel;
private JButton calcButton;
private JButton exitButton;
public CalculatorGUI()
{
super("Joe's Automotive");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_O...
setLayout(new BorderLayout());
sc = new Service();
ns = new NonService();
buildButtonPanel();
add(sc, BorderLayout.NORTH);
add(ns, BorderLayout.SOUTH);
pack();
setVisible(true);
}
private void buildButtonPanel()
{
buttonPanel.add(calcButton);
buttonPanel.add(exitButton);
}
private class CalcButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double total;
total = sc.actionCalculate() +ns.getNonroutineServicesCost();
DecimalFormat dollar = new DecimalFormat("0.00");
JOptionPane.showMessageDialog(null, "Total: $" +dollar.format(total) );
}
}
private class ExitButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// Exit the application.
System.exit(0);
}
}
public static void main(String args[]) {
new CalculatorG

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