Question: Objective: This assignment will give you practice with action event handling The programming assignment In this assignment you are to add functionality to the calculator


Objective: This assignment will give you practice with action event handling The programming assignment In this assignment you are to add functionality to the calculator created in lab 08. You don't have to make the calculator a full function calculator. You only need to make buttons 0 9, +,-, *, / and work. ome programming hints 1. Implement an action listener public void actionPerformed(ActionEvent e) for (int i-0; i-9: +i) if (e.getSource0digitButton[i if (newNumber) display digit in tf newNUmber -false; else append digit in tf, return if (e.getSource0addButton) opndl Double.parseDouble(tf.getText0): newNumber-true; operator- if (e.getSource0eqButton) opnd2 Double.parseDouble(tf.getText0) switch (operator) case : res opndl / opnd2; break; case : res opndl * opnd2; break; case '-': res = opnd l-opnd2; break; case : res- opndl + opnd2; break; display(""+res); newNumber true; return; 2. Register the action listener with all buttons
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
