This is a simple calculator application with a graphical user interface built using Windows Forms in C#. The calculator supports basic arithmetic operations, including addition, subtraction, multiplication, and division. Additionally, it provides the functionality to evaluate mathematical expressions and perform error checking.
- Input buttons for digits (0-9), decimal point, and basic arithmetic operators (+, -, *, /).
- Clear button to reset the input.
- Backspace button to remove the last entered character.
- Equal button to evaluate the entered expression.
- Error checking for invalid expressions and division by zero.
- Additional functionalities: "con" command to open a console window and testing functionality.
- Numeric Input: Click on the numeric buttons (0-9) to enter digits.
- Arithmetic Operators: Click on the buttons (+, -, *, ÷) to enter arithmetic operators.
- Decimal Point: Click on the dot button to insert a decimal point.
- Clear: Click on the "AC" button to clear the input.
- Backspace: Click on the backspace button to remove the last entered character.
- Evaluate: Click on the equal button or press Enter key to evaluate the entered expression.
- Console: Typing "con" in the input box and pressing Enter will open a console window.
- Testing: Typing "test" in the console window and entering a count will perform random tests on the calculator logic.
The calculator logic is implemented in the CalculatorLogic class, providing methods for checking the validity of mathematical expressions (IsValidMathExpression) and evaluating expressions (EvaluateMathExpression). The logic uses a recursive descent parser to handle parsing and evaluating mathematical expressions.
The console window allows users to execute additional commands like "test" for testing the calculator's functionality. The test command performs random tests and displays any discrepancies in the results.
- C# (Windows Forms)
- .NET Framework
- Clone the repository.
- Open the solution in Visual Studio.
- Build and run the Calculator project.
Feel free to contribute or report issues!