Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code Completion 11.105 Combo box with functions Complete this function calculator so that it can compute the functions abs, sqrt, and log10. When the user
Code Completion 11.105 Combo box with functions
Complete this function calculator so that it can compute the functions abs, sqrt, and log10. When the user selects a function name in the combo box, update the output label.
Here is a sample program output:
Complete the following code:
import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JComboBox; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class CalcFrame extends JFrame { private JTextField input; private JLabel output; private JComboBox function; public CalcFrame() { function = new JComboBox(); // Your work here input = new JTextField(10); input.setText("10"); output = new JLabel("Select a function"); setLayout(new FlowLayout()); add(function); add(input); add(output); } }
The following class is used to check your work:
import javax.swing.JFrame; public class CalcFrameViewer { public static void main(String[] s) { CalcFrame frame = new CalcFrame(); frame.setSize(400, 75); frame.setTitle("CalcFrameViewer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }CalcFrame Viewer sqrt 10 abs O X 3.1622776601683795
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