Question 1028498
Do you want a theoretical mathematical formulation?
Look in your book. 
If you want help developing a formula, message me.
You gave "figure A" and "figure B" as if we could magically see them.
We cannot. I will work through the mathematics of developing formulae for rectangular prisms with you, if you are interested, volumes sometimes involve elementary calculus (not in this case). This is more geometry than algebra,but still without the information from the "figures", it becomes an abstract formula problem