Question
I NEED C# PROGRAM PLEASE Objectives Build a GUI application similar to a calculator. Create a application that acts as a simple calculator. Create buttons
I NEED C# PROGRAM PLEASE
Objectives
- Build a GUI application similar to a calculator.
- Create a application that acts as a simple calculator. Create buttons for 0-9 and a text field that displays the concatenation of the current digits as they are clicked.
- Add buttons for operators +, -, *, and /.
- Add a final button for = that calculates the computed value with the value entered in the text field. For instance, clicking buttons 7, +, 8, = should display 15.
Tasks
This assignment has two parts:
- Create a window and add the required GUI elements to it.
- Make an event handler for all the GUI elements that require them.
Task 1 Build the GUIs
Using the knowledge acquired in the labs, construct a GUI window with buttons for the numbers zero (0) through nine (9), and buttons for addition (+), subtraction (-), multiplication (*), division (/) and finally equality (=).
Also add a label/text object that will show the numbers concatenated as the corresponding buttons are pressed. This will be explained more in the following section.
Task 2 Make the Event Handlers
The buttons will need event handlers for when they are clicked. When a button is clicked it should concatenate its number or operator to the current calculation. For example, it should show the value 98 if the buttons 9 and 8 were clicked. However, if an operator button was clicked between two numbers then it should show that operator between the values. So it would show 9 / 8 if the buttons 9, then /, and then 8 were clicked. It is important to note that if we click 9, then 8, then /, and finally 8 we would get 98 / 8.
The equal (=) button is special in that if it is clicked after a viable operation occurs it should replace the whole equation with the result of the calculation. Therefore, we should never see the = in the label. For instance, 98 / 8 evaluates to 12.25, so the label should show 12.25 after the equal sign button is clicked.
NOTE: Assume that the equal sign is only pressed after at least two separate numbers and an operator are entered and that the user will want to use that as their first number for the next operation. That means if a new number is pressed, then it will be added to the end (as the last digit) of the result from the last operation. Also, this should work for at least two (2) digits, but your calculations do not need to work for more than that.
Below is some possible sample output (note: simply means, there exists):
The last button pressed has a dark blue highlight around the edges.
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