Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef Calc_h
- #define Calc_h
- class Calc
- {
- int value;
- public:
- void calc(int a, char oper, int b);
- void calc(char oper, int b);
- int getValue();
- };
- #endif
- //////////////////////////////////
- #include "Calc.h"
- #include <iostream>
- using namespace std;
- void Calc::calc (int a, char oper, int b)
- {
- switch (oper)
- {
- case '+':
- this->value = a + b;
- break;
- case '-':
- this->value = a - b;
- break;
- case '*':
- this->value = a * b;
- break;
- case '%':
- this->value = a % b;
- break;
- }
- return;
- }
- void Calc::calc (char oper, int b)
- {
- switch (oper)
- {
- case '+':
- this->value = value + b;
- break;
- case '-':
- this->value = value - b;
- break;
- case '*':
- this->value = value * b;
- break;
- case '%':
- this->value = value % b;
- break;
- }
- return;
- }
- int Calc::getValue()
- {
- return value;
- }
- ////////////////////////
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include "Calc.h"
- using namespace std;
- int main ()
- {
- int a, b;
- char oper;
- Calc res;
- cin >> a >> oper >> b;
- res.calc (a, oper, b);
- int check = 1;
- cin >> oper >> b;
- while (oper != 'C')
- {
- check++;
- res.calc(oper, b);
- if (check % 3 == 0)
- {
- if (check == 3)
- {
- cout << res.getValue();
- }
- else
- {
- cout << endl << res.getValue();
- }
- }
- cin >> oper >> b;
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement