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

Create an application that will allow the user to investigate the equations show

ID: 3712184 • Letter: C

Question

Create an application that will allow the user to investigate the equations shown below. Use an abstract class or an interface in your design. The GUI below shows the sin function. Your implementation must allow the user to select any one of the equations to be investigated. Use slider controls to allow the user to change the constant values. Use one of the layout managers discussed in chapter 7 and component features in chapter 11 to make your GUI user friendly.

standard layouts such as border, box or grid work and for component features it would be something such as a split pane or combo box. Thank you very much

Equation Tester Graph of the Sine Function Asin (bm + ?) Amplitute Coefficient (A)-3 1 2 345 6 requency Coefficient (b) 12 o 30 60 90 120 150 180 Shift Coefficient (v)--0.105 180 90 90

Explanation / Answer

import java.awt.*;

import javax.swing.*;

import javax.swing.event.*;

public class quadraticpanel extends JPanel

{

   private JPanel controls, graphPanel;

   private JSlider ASlider, BSlider, CSlider;

   private JLabel ALabel, BLabel, CLabel;

   double A, B, C, x,Y;

public quadraticpanel()

   {

      ASlider = new JSlider (JSlider.HORIZONTAL, 0, 255, 0);

      ASlider.setMajorTickSpacing (50);

      ASlider.setMinorTickSpacing (10);

      ASlider.setPaintTicks (true);

      ASlider.setPaintLabels (true);

      ASlider.setAlignmentX (Component.LEFT_ALIGNMENT);

      BSlider = new JSlider (JSlider.HORIZONTAL, 0, 255, 0);

      BSlider.setMajorTickSpacing (50);

      BSlider.setMinorTickSpacing (10);

      BSlider.setPaintTicks (true);

      BSlider.setPaintLabels (true);

      BSlider.setAlignmentX (Component.LEFT_ALIGNMENT);

      CSlider = new JSlider (JSlider.HORIZONTAL, 0, 255, 0);

      CSlider.setMajorTickSpacing (50);

      CSlider.setMinorTickSpacing (10);

      CSlider.setPaintTicks (true);

      CSlider.setPaintLabels (true);

      CSlider.setAlignmentX (Component.LEFT_ALIGNMENT);

      SliderListener listener = new SliderListener();

      ASlider.addChangeListener (listener);

      BSlider.addChangeListener (listener);

      CSlider.addChangeListener (listener);

      ALabel = new JLabel ("a: 0");

      ALabel.setAlignmentX (Component.LEFT_ALIGNMENT);

      BLabel = new JLabel ("b: 0");

      BLabel.setAlignmentX (Component.LEFT_ALIGNMENT);

      CLabel = new JLabel ("c: 0");

      CLabel.setAlignmentX (Component.LEFT_ALIGNMENT);

      controls = new JPanel();

      BoxLayout layout = new BoxLayout (controls, BoxLayout.Y_AXIS);

      controls.setLayout (layout);

      controls.add (ALabel);

      controls.add (ASlider);

      controls.add (Box.createRigidArea (new Dimension (0, 20)));

      controls.add (BLabel);

      controls.add (BSlider);

      controls.add (Box.createRigidArea (new Dimension (0, 20)));

      controls.add (CLabel);

      controls.add (CSlider);

      graphPanel = new JPanel();

      graphPanel.setPreferredSize (new Dimension (500, 500));

      graphPanel.setBackground (Color.white);

}  

public void paintComponent(Graphics page)

   {

     super.paintComponent (page);

     for ( x=-10; x <= 10; x++)

     {

         Y = (A*(Math.pow(x,2)))+(B*x)+(C);

         int g = (int)Math.round(x);

         int h = (int)Math.round(Y);

         page.setColor (Color.black);

          page.fillOval (g, h, 1, 1);

      }

    }

   public class SliderListener implements ChangeListener

   {

public void stateChanged (ChangeEvent event)

      {

         A = ASlider.getValue();

         B = BSlider.getValue();

         C = CSlider.getValue();

         ALabel.setText ("a: " + A);

         BLabel.setText ("b: " + B);

         CLabel.setText ("c: " + C);

      }

   }

}

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