-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (47 loc) · 1.34 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (47 loc) · 1.34 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include "String.h"
#include "Globals.h"
#include <string>
#include <utility>
#include <cmath>
#include <exception>
#include <queue>
#include "MathExpression.h"
using namespace std;
using namespace mpw;
using namespace math_expression;
int main()
{
cout << "Your functions should be in terms of x. \n\n";
while (true)
{
try
{
// sorry; never really learned how to correct this.
fflush(stdin);
std::cout << "Enter in your expression: ";
std::string expression;
std::cin >> expression;
// sorry; never really learned how to correct this.
fflush(stdin);
long double val;
std::cout << "Enter in your value. ";
std::cin >> val;
StrNumberMap foo;
foo["x"] = val;
MathExpression blah(expression);
std::cout << blah.substitute(foo) << endl;
}
catch (Exception const& e)
{
std::cout << e.what() << endl;
std::cout << e.getLineNo() << endl;
std::cout << e.getFileName() << endl;
}
catch (exception const& e)
{
std::cout << e.what() << endl;
std::cout << "STANDARD EXCEPTION";
}
}
}