Skip to content

Instantly share code, notes, and snippets.

@whichbuffer
Last active September 29, 2018 07:38
Show Gist options
  • Save whichbuffer/2fb940f0d52aae0a532d6af821d0c448 to your computer and use it in GitHub Desktop.
Save whichbuffer/2fb940f0d52aae0a532d6af821d0c448 to your computer and use it in GitHub Desktop.
Calculator
#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