Merge branch 'master' of git://git.ucc.asn.au/ipdf/code
[ipdf/code.git] / src / tests / calculator.cpp
1 #include "main.h"
2 #include "real.h"
3 #include <cmath>
4 #include <cassert>
5 #include <list>
6 #include <bitset>
7 #include <iostream>
8
9 using namespace std;
10 using namespace IPDF;
11
12 int main(int argc, char ** argv)
13 {
14         while (true)
15         {
16                 double da; double db;
17                 char op;
18                 cin >> da >> op >> db;
19                 
20                 Real a(da);
21                 Real b(db);
22                 
23                 Real c;
24                 switch (op)
25                 {
26                         case '+':
27                                 c = a + b;
28                                 break;
29                         case '-':
30                                 c = a - b;
31                                 break;
32                         case '*':
33                                 c = a * b;
34                                 break;
35                         case '/':
36                                 c = a / b;
37                                 break;
38                 }
39                 
40                 cout << Double(c) << '\n';
41                 
42         }
43 }

UCC git Repository :: git.ucc.asn.au