Answered step by step
Verified Expert Solution
Question
1 Approved Answer
UML diagram public class Joes Automotive extends JFrame { private RoutinePanel routine; private NonRoutinePanel nonRoutine; private JPanel buttonPanel; private JButton calcButton; private JButton exitButton; //
UML diagram
public class Joes Automotive extends JFrame { private RoutinePanel routine; private NonRoutinePanel nonRoutine; private JPanel buttonPanel; private JButton calcButton; private JButton exitButton; // A panel for routine charge checkboxes // A panel for non-routine charges // A panel for the buttons // Calculates everything // Exits the application private void buildButtonPanel() { // Create a button to calculate the charges. calcButton = new JButton("Calculate Charges"); // Add an action listener to the button. calcButton.addActionListener(new CalcButtonListener(); public Joes Automotive() // Create a button to exit the application. exitButton = new JButton("Exit"); // Display a title. super("Joe's Automotive"); // Add an action listener to the button. exitButton.addActionListener(new ExitButtonListener(); // Specify what happens when the close button is clicked. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a RoutinePanel object. routine = new RoutinePanel(); // Put the buttons in their own panel. buttonPanel = new JPanel(); buttonPanel.add(calcButton); buttonPanel.add(exitButton); } private class CalcButtonListener implements ActionListener { // Create a NonRoutinePanel object. non Routine = new NonRoutinePanel(); public void actionPerformed (ActionEvent e) double totalCharges; // Total charges // Build the panel that contains the buttons. buildButtonPanel(); // Create a DecimalFormat object to format output. DecimalFormat dollar = new DecimalFormat("#,##0.00"); // Add the panels to the content pane. add(routine, BorderLayout. NORTH); add(nonRoutine, BorderLayout.CENTER); add (buttonPanel, BorderLayout.SOUTH); // Calculate the total charges totalCharges = routine.getCharges() + nonRoutine.getCharges(); // Pack and display the window. pack(); setVisible(true); // Display the message. JOptionPane.showMessageDialog(null, "Total Charges: $" + dollar.format(totalCharges)); } } // End of inner class } private class ExitButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(); } // End of inner class public static void main(String[] args) { JoesAutomotive jaw = new JoesAutomotive(); } public double getcharges() { double charges = 0; public class RoutinePanel extends JPanel { private final double OIL_CHANGE_CHARGE = 26.0; private final double LUBE_JOB_CHARGE = 18.0; private final double RADIATOR_FLUSH_CHARGE = 30.0; private final double TRANS_FLUSH_CHARGE = 80.0; private final double INSPECTION_CHARGE = 15.0; private final double MUFFLER_CHARGE = 100.0; private final double TIRE_ROTATION_CHARGE = 20.0; private JCheckBox oilChange; // Check box for oil change private JCheckBox lube Job; // Check box for lube job private JCheckBox radiatorFlush; // Check box for radiator flush private JCheckBox transFlush; // Check box for transmission flush private JCheckBox inspection; // Check box for inspection private ICheckBox muffler; // Check box for muffler replacement private JCheckBox tireRotation; // Check box for tire rotation if (oilchange. isSelected()) charges += OIL_CHANGE_CHARGE; if (lubeJob.isselected()) charges += LUBE_JOB_CHARGE; if (radiatorFlush.isselected()) charges += RADIATOR_FLUSH_CHARGE; if (transFlush.isselected()) charges += TRANS_FLUSH_CHARGE; if (inspection.isSelected()) charges += INSPECTION_CHARGE; if (muffler.isselected()) charges += MUFFLER_CHARGE; if (tireRotation.isSelected()) charges += TIRE_ROTATION_CHARGE; public RoutinePanel() return charges; } } DecimalFormat dollar = new DecimalFormat("#,##0.00"); oilChange = new JCheckBox ("Oil Change ($" + dollar.format(OIL_CHANGE_CHARGE) + ")"); lube Job = new JCheckBox("Lube Job ($" + dollar.format(LUBE_JOB_CHARGE) + ")"); radiatorFlush = new JCheckBox("Radiator Flush ($" + dollar.format(RADIATOR_FLUSH_CHARGE) + ")"); transFlush = new JCheckBox("Transmission Flush ($" dollar.format(TRANS_FLUSH_CHARGE) + ")"); inspection = new JCheckBox("Inspection ($" + dollar.format(INSPECTION_CHARGE) + ")"); muffler = new JCheckBox("Muffler Replacement ($" + dollar.format(MUFFLER_CHARGE) + ")"); tireRotation = new JCheckBox("Tire Rotation ($" + dollar.format(TIRE_ROTATION_CHARGE) + ")"); setLayout(new GridLayout(7, 1)); setBorder(BorderFactory.createTitledBorder("Routine Services")); add(oilChange); add(lube Job); add(radiator Flush); add(transFlush); add (inspection); add(muffler); add(tireRotation); }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started