The following function returns a Boolean value indicating whether the inputs are in the correct range. If
Fantastic news! We've Found the answer you've been seeking!
Question:
The following function returns a Boolean value indicating whether the inputs are in the correct range. If they are, it updates the value of vol to be the volume.
bool volume(double w, double h, double d, double &vol)
{
if(w<0 || h<0 || d<0)
return false;
vol = w*h*d;
return true;
}
a. Rewrite it so that it returns the volume and throws an exception if the inputs are invalid.
b. Write a code fragment which tries to call your rewritten volume function with and prints "could not compute volume" if it catches any exceptions.
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date: