-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (52 loc) · 1.26 KB
/
main.cpp
File metadata and controls
58 lines (52 loc) · 1.26 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
56
57
58
#include <iostream>
#include <conio.h>
#include "Calculator.h"
using namespace std;
void menu();
void calculate() {
char s[100];
system("cls");
cout << "Enter an string for calculating:" << endl;
cin >> s;
Calculator m;
Node *n = m.maketree(s);
cout << "Result is:" << m.value(n);
cout << endl << "if you want goto menu press m";
char ch = getch();
if ((ch == 'm') || (ch == 'M')) menu(); else calculate();
}
void about() {
system("cls");
cout << "This program takes a mathematical expression as a string, constructs a tree representation of the expression, "
<< endl;
cout << "and evaluates the result.";
cout << "Developer:Rohollah(Mehrad) Mehri" << endl;
getch();
menu();
}
void menu() {
system("cls");
cout << " Menu:" << endl;
cout << " C-Calculate" << endl;
cout << " A-About" << endl;
cout << " E-Exit" << endl;
cout << " please select a choice:";
char ch = getch();
switch (ch) {
case 'c':
case 'C':
calculate();
break;
case 'a':
case 'A':
about();
break;
case 'e':
case 'E':
exit(0);
}
}
int main() {
menu();
return 0;
}