Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the program below Calcularor.exe but following an Object Oriented appr

ID: 3643081 • Letter: I

Question

Implement the program below Calcularor.exe but following an Object Oriented approach. Object oriented design and implementation, Menu-driven program schema, input data validation.

This is Calculator.cpp, i only need calculator.h

#include <iostream>
#include "Calculator.h"
using namespace std;

int main(void){
Calculator c;
char op;

do{
switch( op=c.ShowCalculator()){
case 'a': c.Add(); break;
case 'b': c.Subtract(); break;
case 'c': c.Multiply(); break;
case 'd': c.Divide(); break;
default: c.Setop(-1);
}
}while(op!='q'&& op!='Q');

return 0;
}

Explanation / Answer

class Calculator{

public :

char ShowCalculator(){

// Display code, if uses GUI

char c;

cin>>c;

return c;

}

void Add(){

int a,b;

cin >> a >> b;

cout << a+b;

}

void Subtract(){

int a,b;

cin >> a >> b;

cout << a-b;

}

void Multiply(){

int a,b;

cin >> a >> b;

cout << a * b;

}

void Divide(){

int a,b;

cin >> a >> b;

if(b!=0)

cout << a/b;

else

cout << "Division by zero";

}

void Setop(int k){

// couldn't see the use of this function

// add appropriate code here

}

}