Okay so I know practically nothing about creating mathematical applications in C++ but am trying to learn. Practically everything I search for isn't anything close to what I need. Basically, I need to lean how to make a calculator style app first before continuing on, however I can't find anyone to teach me. Then to top it off, I then need to step it up to where the app can solve complex expressions and equations. When I say complex I'm meaning basic algebra. Not too hard to do, still harder than basic math.

My main concern is polynomials because they are the most interesting to me. I need the user to be able to type in a complete polynomial and the application to solve it with or without the variable assignments.

Example:
// Please note I don't know how to do powers so if a number is an exponent it will have ^ before it.
a = (3x^2 − 4x + 8) + (2x^2 + 5x −12);

This simplifies to a = (5x^2 + x - 4).

The application would have to simplify the problem given. The next example x is given. I want the application to scan the user input for the variables and ask if they have given values. (This is if the user isn't smart enough to exchange them already.

x = 4;
a = (3x^2 − 4x + 8) + (2x^2 + 5x −12)
a = (5x^2 + x - 4)

Simplify;

a = (5 * 4^2 + 4 - 4)
a = (5 * 16 + 4 - 4)
a = (80 + 4 - 4)
a = (84 - 4)
a = 80;

So that's all the information I really have, I just want to learn this, so anyone willing to teach me would be awesome. You would have eternal thanks. (Oh and sorry if the step by step bugs you, it's just a habit of mine. I kind of want the application to show the steps as well.)

// Talk about starting from scratch.
#include <iostream>

using namespace std;

int main()
{
system("pause")
return 0;
}

You need to look up how to translate infix (normal a+b) notation into something like reverse polish notation (ab+). RPN makes it easy to calculate an equation. But the translation into RPN is a little harder. Especially when parentheses are part of the equation.

See http://www.google.com/search?q=infix+to+reverse+polish

Unless this is an assignment I would use a library to do this.

Otherwise, some creative design could likely solve the problem, you may want to work out some pseudo-code for the entire program.

It may go something like:

-order-of-operations scan, instantiation of evaluator class if required. Innermost expression is evaluated first, in groups of two "terms".

i.e.,
input: 3 + 8 / 10
evaluator: 8 / 10

-replace "terms" with result.

i.e.,
input: 3 + 0.8

-continue until evaluated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.