Objective : To program a simple 4 function calculator with a memory that doesn't allow a user to see incorrect results by not allowing invalid buttons to be pressed.
Concepts: Control Arrays, Defensive Design
Assume you're trying to build a simple calculator that looks something like this: (note, you can be creative and design your calculator in any way you want). Note, too, that by double-clicking this image, you'll be able to invoke an almost complete calculator to try out. Note, this sample calculator does not have the required MC (Memory Clear), M+ (to add something to memory), and MR (Memory Recall) functions.
Your calculator needs to allow for processing --
- Multiple digit numbers;
- Decimal points;
- Addition, subtraction, multiplication and division
- Exponentiation would be great, and square root
- Conversion to/from Hex <--> Decimal (extra credit)
- The equal sign to finalize an expression
By appropriate use of the .enable property for command buttons, your code should, at the appropriate times, disable and then enable specific buttons from being clicked. No, you don't have to deal with input from the keyboard … concentrate only on the code that will be invoked when someone clicks on one of the calculator buttons.
Testing: Try your program out with one digit and multiple digit numbers. Be sure that the correct values are displayed with each and every button click. If you are allowing for complex expressions (e.g. 1+2*3) then, again, be sure the correct values are displayed with every mouse click. YOU can decide what types of expressions you want to process. Finally, if pressing a specific button causes a calculation error or invalid data to be displayed, you need to put in code to prevent that situation from even occurring.
Due: 2 Weeks (Feb 16); You must demonstrate your program in front of the room - failure to do so results in a zero. No email submissions are allowed nor will be accepted. Under no circumstances will the lab be accepted late. DEADLINE MEANS DEADLINE.
Posted: - Feb 2.