Question: Exercise 5 Create a calculator class with the following methods: Add, Subtract, Multiply, Divide, and Modulus. Each method takes two numbers and returns the result
Exercise 5
Create a calculator class with the following methods: Add, Subtract, Multiply, Divide, and Modulus. Each method takes two numbers and returns the result of the corresponding operation.
-
Create a simple calculator GUI: Create a new JFrame Form and use the Palette to drag and drop the Swing Containers and Controllers like the figure shown. Use the class Calculator you developed in 1 in running your JFrame.
The user will use the number pad to enter the number. If the user enters 812 for example, then presses the operation button *, he can enter another number 10. When the user presses the button =, the result text field shows the result of the multiplication of the two numbers: 812 * 10 = 8120
Hint: The clear button should set all text fields to the empty string . The operation buttons should clear the Number text field as well. Hint: The status label should indicate an error if the user divides by 0 ( / 0 or % 0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
