-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
36 lines (30 loc) · 1.02 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "DataLoader.h"
#include "Node.h"
#include "PrefixExpression.h"
#include "InvalidExpressionError.h"
int main() {
std::cout << "Please input file name: ";
std::string fileName;
std::cin >> fileName;
try {
DataLoader loader{fileName};
std::cout << "\n" << loader.getExpressionString() << "\n";
PrefixExpression expression{};
expression.load(loader);
std::cout << "Expression in prefix notation: ";
expression.print(std::cout);
std::cout << "\nExpression in standard notation: ";
expression.printInStandard(std::cout);
expression.simplify();
std::cout << "\nSimplest form of expression: ";
expression.printInStandard(std::cout);
std::cout << "\nExpression evaluates to: " << expression.calculate();
if (expression.hasX())
std::cout << "\n with x = " << expression.getXValue();
} catch (InvalidExpressionError& error)
{
std::cout<<error.what();
}
return 0;
}