This program, is the simple calculator. I'd a task, to write something like this, but the "original" one is a little bit more complicated. Problem in input ( again :D ), when i enter decimal numbers, the result if 0, in any case. How should I take the input?
I would use std::getline(cin, myString); then parse the information you need from the string. Then use std::stringstream to convert from the string bits into floats/doubles for your calculations.
That depends on how you decide to split the string and pass the pieces off to your other methods. Start simple, ask them to insert and equation and work on isolating the various pieces as strings. Print these to the screen.
Once you accomplish this, work on the conversion and actually doing some calculations. Having them split nicely in the beginning will make you work a lot easier as you progress.
for (int j=0; j < div.size(); j++)
{
if ( div[j] == '*')
{
int *ptr = div[j];
int x = div[--j] - 48;
int y = div[j+2] - 48;
mult = x*y;
break ;
}
elseif ( div[j] == '+')
{
int x = div[--j] - 48;
int y = div[j+2] - 48;
sum += x+y;
break;
}
}
If i continue so, in case of 3+2*5, where shall I store 2*5's result?