Question: #include #include #include #include #include using namespace std; #include expression.h #include subexpression.h #include symboltable.h #include parse.h SymbolTable symbolTable; std::ifstream fin (

#include
#include
#include
#include
#include
using namespace std;
#include "expression.h"
#include "subexpression.h"
#include "symboltable.h"
#include "parse.h"
SymbolTable symbolTable;
std::ifstream fin("C:/path/to/input.txt");
void parseAssignments(std::stringstream& in){
char assignop, delimiter;
std::string variable;
double value;
do {
variable = parseName(in);
in >> std::ws >> assignop >> value >> delimiter;
symbolTable.insert(variable, value);
} while (delimiter ==',');
}
int main(){
const int SIZE =256;
char line[SIZE];
std::ifstream fin("input.txt");
if (!fin){
std::cerr << "Error: Unable to open input file." << std::endl;
return 1;
}
while (fin.getline(line, SIZE)){
std::stringstream in(line);
try {
char paren;
in >> paren;
Expression* expression = SubExpression::parse(in);
char comma;
in >> comma;
parseAssignments(in);
double result = expression->evaluate();
std::cout << line <<"="<< result << std::endl;
} catch (const std::exception& ex){
std::cerr << "Error: "<< ex.what()<< std::endl;
}
}
return 0;
}((a +4) ~), a =3;
((x *2.6)+(y -3)), x =1.5, y =6;
((7/ z_1)+(z_1^2)), z_1=2;
((6% b)<5), b =4;
(c > d), c =9, d =7;
(e & 8), e =5;
(f ?12), f =0;
(g # 123), g =2;
(tt + ss), tt =2;
(aa +1), aa =1, aa =2; for some reason my code cant open up the input text file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!