Last active
September 29, 2018 07:38
-
-
Save whichbuffer/2fb940f0d52aae0a532d6af821d0c448 to your computer and use it in GitHub Desktop.
Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Calculator | |
{ | |
public: | |
int Calculate (int , int , char); | |
}; | |
int main (){ | |
int x , y ,result; | |
char oper; | |
cout<<"Merhaba Ben Bir hesap Makinesiyim"<<endl; | |
cout<<"Sayı gir num1 ve num2: "<<endl; | |
cin>> x >> y >> oper; | |
Calculator c; | |
result = c.Calculate(x,y,oper); | |
cout<<"YANIT: "<<result<<endl; | |
cin.ignore(); | |
cin.get(); | |
return 0 ; | |
} | |
int Calculator::Calculate(int x, int y, char oper) { | |
switch (oper){ | |
case '+':return x+y; | |
case '-':return x-y; | |
case '*':return x*y; | |
case '/':if (y!=0) return x/y; | |
default: | |
return 0 ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment