rendered paste body#include<iostream>
using namespace std;
class newHelloWorld{
private:
int op1, op2, result;
char op;
public:
newHelloWorld(void){
//Default Constructor
}
void input(void){
cout<<"\nEnter first operand : ";
cin>>op1;
cout<<"+ (for addition), \n- (for subtraction), \n* (for multiplication), \n/ (for division) and\n% (for modulus) \nEnter (from above) operation: ";
cin>>op;
cout<<"Enter second operand: ";
cin>>op2;
}
void operation(){
switch(op){
case '+': result = op1 + op2;
break;
case '-': result = op1 - op2;
break;
case '*': result = op1 * op2;
break;
case '/': if(op2!=0)
result = op1/op2;
else{
cout<<"Invalid value for second operand. Quitting\n";
exit(1);
}
break;
case '%': if(op2!=0)
result = op1%op2;
else{
cout<<"Invalid value for second operand. Quitting\n";
exit(1);
}
break;
default: cout<<"\nAbnormal termination due to wrong input of operation\n";
exit(1);
}
}
void display(void){
cout<<op1<<" "<<op<<" "<<op2<<" ="<<" "<<result<<"\n";
}
};
int main(void){
newHelloWorld hwobj;
hwobj.input();
hwobj.operation();
hwobj.display();
}