-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (42 loc) · 1.55 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include "app/classes/Calculator.h"
#include "app/classes/Calculation.h"
#include "app/classes/CalculatorGUI.h"
#include <QApplication>
#include <QDebug>
using namespace std;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
CalculatorGUI addressBook;
addressBook.show();
return app.exec();
double result;
std::string equation;
cout << "Calculator Console Application" << endl << endl;
cout << "Please enter the operation to perform." << endl;
cout << "Allowed operators: a+b | a-b | a*b | a/b | a:b | a^b | arb (for a√b) | ( | )" << endl;
cout << "For the history type 'h' " << endl;
Calculator calc;
while (true) {
char input[50];
cin.getline(input, 50);
//we will print the history if the user inputs an h
if (input[0] == 'h'){
for(int i=0; i < calc.getFullHistory().size(); i++){
cout << "[" << i+1 << "]Die Rechnung " << calc.getFullHistory().at(i).getFullCalculationString() << " ergab: " << calc.getFullHistory().at(i).getResult() << endl;
}
continue;
}
//we will end the loop if the user enters an e
if (input[0] == 'e'){
break;
}
//creates a new calculation inspired by the user input
Calculation m_calculation = calc.calculation(input);
result = m_calculation.getResult();
equation = m_calculation.getFullCalculationString();
cout << "Result to " << equation << " is: " << result << endl;
}
return 0;
}