Question
A form that lets the user perform the operations provided by a basic calculator. Needs a class that performs the required operations. The design of
A form that lets the user perform the operations provided by a basic calculator. Needs a class that performs the required operations.
The design of the Calculator form
Operation
To perform an addition, subtraction, multiplication, or division operation, the user clicks the first number, followed by the appropriate operator key (+, -, *, /), followed by the second number and the equals key (=). Each time the equals key is clicked, the operation is repeated.
To calculate the square root or the reciprocal of a number or to change the sign of a number, the user clicks the number followed by the appropriate operator key (sqrt, 1/X, +/-). Each time the user clicks the operator key, the operation is repeated.
Each time the user clicks a number key, the number is displayed in the text box at the top of the form. This text box also displays the result of an operation when the user clicks the sqrt, 1/X, +/-, or = key.
To erase the last digit entered, the user clicks the Back key.
To clear all the values entered; the user clicks the Clear key.
Specifications
Class named Calculator that implements the functions of the calculator. Design whatever methods and properties you need for this class.
The Calculator class should accept decimal parameters and provide a decimal result for its calculated values.
If the user tries to divide a number by zero, the calculator should display an error message in the text box. The form class should use a try-catch statement to catch a divide-by-zero exception.
cal.png
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