// Geoff Hagopian PPP4 exercise 5

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

double calculate(double, double, char);

int main() {
	double operand1, operand2;
	char operation;
	cout << "Enter two double operands followed by an operation: ";
	while (cin >> operand1 >> operand2 >> operation) {
		cout << operand1 << operation << operand2
			<< " = " << calculate(operand1, operand2, operation);
	}
}

double calculate(double x, double y, char op) {
	switch (op) {
	case '+' :
		return x + y;
	case '-':
		return x - y;
	case '/': {
		//if (y == 0) throw runtime_error("division by zero");
		//else 
		return x / y;
	}
	case '*':
		return x * y;
	default :
		cerr << "I don't know that operation.\n";
		return 0;
	}
}