Write a function which computes the value of an arithmetic expression. The op should be one of ('+', '-', '*', or '/'). The function should throw an invalid_argument exception otherwise. You should...


Write a function which computes the value of an arithmetic expression. The op should be one of ('+', '-', '*', or '/'). The function should throw an invalid_argument exception otherwise. You should also Also throw an invalid_argument if the op is '/' and the second argument is zero.


#include
#include
using namespace std;


/**
Computes the value of an arithmetic expression.
@param value1 the first operand
@param op a char that should contain an operator + - * or /
@param value2 the second operand
@return the result of the operation

*/
int compute(int value1, char op, int value2)
{


...


}



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here