Calculator is a simple scientific console calculator capable of handling complex arithmetic expressions along with some basic trigonometric functionality.
Upon launching the application, the program will be in solve/calc mode, where the user can enter equations for the program to solve. The expressions must be valid, otherwise, the program will display an error message.
> 3 + 8 * ((4 + 3) * 2 + 1) - 6 / (2 + 1)
121
> 1 + 2 ^ 5
33
> (( 4 + 1
Invalid expression! Invalid parentheses order!
The user can assign values to variables and can, consequently, create functions with nested variables. For example, in trying to find the root of the equation
By definition,
Letting x = 10 be a starting point, we can solve the problem as follows:
> 10
10
> func = ans - (ans^2 + ans - 3)/(2ans + 1)
Assigned!
> func
4.904761904761905
> func
2.503041745332494
> func
1.542638891596777
> func
1.316858983738793
> func
1.3028302211191816
...
It is important to note that nested variables are dynamic, meaning that if a variable in a variable changes, the value of the parent variable changes as well. Another important note is that the variable 'ans' takes the value of the last computed expression and can be used in a variable as well - as demonstrated above.
By default, the angle is set to degrees. This can be changed by entering
> /angle rad //or radians
or
> /angle deg //or degrees
Due to round-off errors using C#'s Math's class, not all answers will be 100% precise, as demonstrated below.
> sin 30
0.49999999999999994
> tan 45
0.9999999999999999
> sin 90
1
> cos90
6.123233995736766E-17 //which is basically 0 at this point
> sqrt4
2
> cbrt 8
2
> qtrt 16
2
> 16^(1/4)
2
> 32^(1/5)
2
Made solely using C#.
As charming and function packed as the default Windows calculator was, it was always missing the support for copy paste solving expressions - like
I first had to develop a system to split an equation into its components:
From there, I decided to add more features, like being able to assign variables. I had to add a hashmap that stores initialized variable names and their corresponding value. After that, before an expression gets solved, the program goes through all components, checking if it is a variable and then substituting its value if initialized. If not, the program throws an error.
After that, I added less important features, such as trigonometric functions; sqrt, cbrt, qtrt functions; etc.
N/A WAIT