Question: Write a function called tankVolume that computes the volume of water in the tank. The function should take exactly five input arguments in this order:

Write a function called tankVolume that computes the volume of water in the tank. The function
should take exactly five input arguments in this order: ,,,, and . It should return exactly one
return value, the volume of water in the tank. Your function should validate the input. More specifically,
check that all input values are greater than zero and that <=(+). If any of the inputs are invalid,
the function should return a value of -1. Test your function by the using the testTankVolume test stub.
Problem 1 Pseudo Code
begin function
% return variable: vol
% Check for negative input values
if ra is negative
vol =-1
return
end
if ha is negative ...
if rb is negative ...
if hb is negative ...
if h is negative ...
% If input values are non-negative, compute the volume
if h < ha
vol =...% use the first equation (the one for a cylinder)
else if h is greater than ha and less than or equal to ha+hb
compute rw
vol =...% use the second equation (the one for cylinder + frustrum)
else
% in this case the value of h is invalid
vol =-1
end
end of function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!