Calculator is a simple number computing device and building it is a complex task. However if we forget about hardwire complexity behind it and shift ourselves to the software technology, making computing device, i.e. calculator is not much difficult. All you need is little bit of logic, mathematics and programming. Being a communication engineer, Matlab is my best programming platform and I love to have some fun with it in free time. I have made two different calculators, one having simple input output and another having numeric keypad and display using Matlab GUI.
As shown in figure above is my “calc.m” which is able to calculate basic operations: add, subtract, multiply and division. To use this calculator, first give inputs and then choose operator and then click to result button. You have to strictly follow these steps: input, choose operator and result, each time you change inputs or operator to get the correct result. To view the source code, click here.
This is “calculator.m” able to calculate basic four mathematical operations. To use this, click CE button at first so that it shows display 0. Now you can start computing like clicking 9, then 5 so that it displays 95 as your first number. Then click operator like +. Then give second number like clicking 5. Now click = button to see the result as 100 in this case. To start next computation always click CE button, otherwise you will get wrong result. To view the source code, click here.
No comments:
Post a Comment