Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specifications Build a simple class using the following specifications ArithmeticManager class Variables: operand1, operand 2 (double) Methods: Value return methods that will add, subtract, multiply,

Specifications

Build a simple class using the following specifications

ArithmeticManager class

Variables: operand1, operand 2 (double)

Methods: Value return methods that will add, subtract, multiply, and divide the two operands

Set/get methods for both variables

A parameterized constructor to set the initial operand values as object is constructed

Access the provided graphical user interface at:

http://websites.delta.edu/teklingl/cs1/inpgm2/

however this is incomplete. Once you complete your class, integrate on object of your class into a project that will create a simple application to perform basic arithmetic on two numbers. Your program should include the following behaviors:

As it is launched, initialize your object with the provided basic dialog box prompts

When the user pressed any button, get the values in the respective text fields, set the data in your object, perform the operation, and finally set the result from the method call the answer text field.

// Delta College - CST 183 - In-Class Program 2 // This program allows the user to manage operands and operations // for basic binary arithmetic operations import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ArithmeticGUI extends JFrame implements ActionListener { // Variables JLabel operand1Label, operand2Label, answerLabel; JTextField operand1field, operand2field; JTextField answerField; JButton addButton,subtractButton,multiplyButton,divideButton; public ArithmeticGUI() { // Set up GUI Container appWindow = getContentPane(); appWindow.setLayout ( new FlowLayout() ); // Operand 1 operand1Label = new JLabel( "Operand 1" ); appWindow.add( operand1Label ); operand1field = new JTextField( 4 ); appWindow.add( operand1field ); // Operand 1 operand2Label = new JLabel( "Operand 2" ); appWindow.add( operand2Label ); operand2field = new JTextField( 4 ); appWindow.add( operand2field ); // Arithmetic operations addButton = new JButton( "Add" ); addButton.addActionListener( this ); appWindow.add( addButton ); subtractButton = new JButton( "Subtract" ); subtractButton.addActionListener( this ); appWindow.add( subtractButton ); multiplyButton = new JButton( "Multiply" ); multiplyButton.addActionListener( this ); appWindow.add( multiplyButton ); divideButton = new JButton( "Divide" ); divideButton.addActionListener( this ); appWindow.add( divideButton ); // Handle answer text field answerLabel = new JLabel( "Answer" ); appWindow.add( answerLabel ); answerField = new JTextField( 7 ); answerField.setEditable( false ); appWindow.add( answerField ); // Get initial fraction value String op1String = JOptionPane.showInputDialog( "Enter operand 1" ); String op2String = JOptionPane.showInputDialog( "Enter operand 2" ); // Set application window attributes setTitle( "Arithmetic Manager" ); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setSize( 800, 300 ); setVisible( true ); } // end constructor // Handle all action events with this method public void actionPerformed( ActionEvent event ) { } // end actionPerformed // Main method public static void main( String args[] ) { ArithmeticGUI application = new ArithmeticGUI(); } // end main } // End class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Exercise 3 - 7 ( Algo ) Adjusting and paying accrued wages LO P 3

Answered: 1 week ago