IT 232 PUG A Working Calculator for Multiplication & Addition Project – Description
Assignment Instructions
You will complete a program to demonstrate the skills presented in this lesson for your selected language path. Please keep in mind that with all the assignments in this course, any given scenarios are hypothetical and intended solely to demonstrate specific skills.
Using the language in which you have chosen to focus: C#, Java, Web Development language (JavaScript), please complete the following Assignment: I HAVE CHOSEN C#.
You will create a GUI calculator program that will offer the user a button to clear the values, buttons for all digits 0 through 9, as well as the operator buttons for multiplication, division, addition, subtraction, and equal. The user should be able to click the various digit buttons and have them display combined as a single number in a textbox or label control. (e.g., if the user clicks the 2, 4 and 7 buttons successively the textbox or label should display 247) If the user clicks on an operator button the current value must be included in the running total based on the last operator button clicked. If no operator button has been clicked since the start of the program or since the last time the clear button has been clicked, then the current value will be added to the total by default. When the equal button is clicked, the current value will be added or subtracted from the total per the previous operator button and then the final total will be displayed in the textbox or label. Note: As mentioned, you can choose to use either a textbox or a label control for displaying data but whichever you choose, only one should be used. (All of this mimics a standard calculator that you have used before.)
ASSIGNMENT REQUIREMENTS
Your program should display a form with either a textbox or label control across the top. Below that, the form should display the buttons described in the assignment description above. (You might want to look and the Windows Calculator or the calculator app on your phone for an example of the layout.)
Name all of your controls suitable names. Hint: prefixes can make control names easier to distinguish one from the other. Examples include cmd for command button, txt for textbox, and lbl for label. Standard naming conventions are common in the software development field.
All buttons should be the same size and neatly aligned in a grid pattern below the textbox/label. How you layout the grid is up to you but I would recommend sticking with the standard pattern for calculators. If you would like your operator buttons to be a different size from your digit buttons that is fine but all operator buttons should be the same size and all digit buttons should be the same size. All buttons should display their value on their face and be centered.
Define any variables you need to keep up with what operator was last clicked as well as the running total. Hint: This can be done with one variable for the total and one variable to indicate the last operator clicked.
Using events for the buttons, add functionality to each button.
Digit buttons should append their respective digit to the end of the displayed number.
Operator buttons should call for currently displayed value to be added or subtracted per the last operator called and then set the operator “flag” variable to indicate what was just clicked. Either the operator button’s code or the next digit button clicked will need to clear the display.
The equal button should call for the last operation to be completed just as the other operators do, then display the final total in the textbox/label control.
The clear button should clear the textbox/label, (either make it blank or make it display 0), as well as reset all variables as they were when the program began.
EXPECTED OUTPUT
A working calculator for multiplication, division, addition, and subtraction.
The post IT 232 PUG A Working Calculator for Multiplication & Addition Project first appeared on .