I would suggest maybe trying to keep away from platform-specific APIs unless there's a need of some sort (example: a requirement for a function that either doesn't exist or isn't/can't be well-implemented using a cross-platform library). That's a personal opinion, though.
I'd suggest the Qt framework. It's a bit large, but it has almost everything you could possibly need for application development, it comes with some useful tools, and it's cross-platform. :)
I'd love to see this calculator given a nice GUI; the GNOME project pretty much wrecked their (previously) awesome calculator and I haven't yet found one that mixed a good GUI and decent features.
If you want, programmatic, I can help you (via AIM, its a IM chat program) make this into a GUI application within a max time of ten hours all together ;) (that is with me teaching you all the code completely)
If I were to make an attempt at parsing equations (which I have tried in previous versions of the calculator), would i have to read each character in a string and determine if it is a number, operator, decimal pt., etc. or is there a way to do this more efficiently. From my past experiences, it gets pretty complicated once you start reading numbers because if the next character is a number it changes the value of the final number and things get pretty tricky.
You could use enums in the menu selection (also changing the if-else to switch-case)
1 2 3 4 5 6 7
//quadratic.cpp
int* PrimeFactor(double d) {
int factors[50];
//...
return factors; //address of local variable returned
}
//factoring calculator.cpp (is this repeated?) has the same issue.
In Quadratic::GetSquareRoot() you are reinventing the wheel in a real inefficient way. Why don't you use sqrt ?
1. Quadratic.cpp and Quadratic.h are files from a previous version of the calculator that I integrated into version 2 (I did a lot of consolidating). Sorry for including them. I guess I forgot to delete them.
2. The GetSquareRoot() function has a misleading name; its purpose is not to find the square root of something, but it is rather to find the number under the radical sign reduced to a non-perfect square.
Also, what do you mean by using enums in the menu selection?
about parsing.
consider input "2+3*(4+5)"
then (ignoring things in parentheses) find the operator of lowest precedence ( + or - ) and split it at that place.
you get 2 and "3*(4+5)"
"3*(4+5)" becomes 3 and "(4+5)".
if there are no operators in the string, try removing the parentheses. you then have "4+5". repeat the operation and you'll get 4 and 5.
you should have a function float evaluate(constchar* input); to do the job:
if input has operators, split it and return evaluate(first_half) + evaluate(second_half);
else if input has parentheses, return evaluate(input_without_parentheses);
if input is "number", return number;
for (unsignedint i = 0;i < sCalculation.length();++i) {
if (IsOperator(sCalculation[i])) {
cOperator = sCalculation[i];
//Store left side number
for (unsignedint j = i - 1;j >= 0;j--)
if (IsNumber(sCalculation[j]))
iLeftSide += GetNumber(sCalculation[j]) * static_cast<int>(pow(static_cast<double>(10), static_cast<int>(i - j - 1)));
//Store right side number
for (unsignedint j = i + 1;j < sCalculation.length();j++)
if (IsNumber(sCalculation[j]))
iRightSide = iRightSide * 10 + GetNumber(sCalculation[j]);
}
}
if you enter "2 + 2", cin >> will read "2" (it stops at gaps) use getline instead.
line 27 has way too much casting.
overall your number parsing is a bit complex and only works for ints. let someone else do the work for you, when you can: http://www.cplusplus.com/articles/numb_to_text/
don't use ints everywhere. or 1 / 2 will be 0.
do that recursive function for more complex inputs.
It's really unorganized and messy so forgive me. If anybody has suggestions for how to separate the code into a non-linear form please tell me. Any suggestions are as always encouraged.