In: Computer Science
Context:
Imagine that a company in the freight transport business has commissioned you to solve the following problem. Given bulk cargo with a certain weight per m3, compute the volume of that bulk cargo in m3 that a single 40-foot standard container can hold. A standard 40-foot container: has an internal volume of 67.5 m3 a maximum net load of 26199 kg . For instance, 1 m3 of gravel weighs 1800 kg. Because the maximum net load of a container is 26199 kg, a single container can only hold 14.555 m3 of gravel, otherwise it would exceed the maximum net load. For comparison, 1 m3 of wood chips weighs 380 kg. Because the maximum net load of a container is 26199 kg, based on the maximum weight, it is allowed to hold 68.94 m3 of wood chips. However, the internal volume of a single container is only 67.5 m3, so a single container can hold 67.5 m3 of wood chips. In answer to this question you will need to decompose the problem, write an algorithm, and implement the algorithm as a single python function that returns the total volume that can be held by single container.
Question: Include your initial decomposition of the problem in your solution document using the chevron notation (> and >>) from the module materials.
SOLUTION-
I have solved the code in python and given screenshot also for easy understanding :)
CODE-
def container_vol(total_weight):
max_net_load=26199
#the maximim load of the container
internal_volume=67.5 #the maximum
volume of the container
volume=max_net_load/total_weight; #calculating the volume bases on the weight of 1 m3
if volume<=internal_volume:
#if volume less than the internal volume
return
volume
#return the calculated volume
else: #if
volume is greater than the internal volume
return
internal_volume #return the internal
volume
def test_container_vol():
#Test the container_vol function.
# Test for gravel at 1800 kg per cubic
metre
assert container_vol(1800) == 14.555
# Test for wood chips at 380 kg per cubic
metre
assert container_vol(380) == 67.5
print ("All test's passed")
test_container_vol()
SCREENSHOT-
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I
WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------