Although we can first calculate the cost of one cap and then can multiply it with 40 to get the result.
but we will solve it with chain rule so that we can prepare ourself for other complex problems which we can solve easily by applying this rule.
Let the required cost be Rs. x
More caps means More Cost. (Direct Proportion)
15:40::240:x
=>x=240*40/15
=>x=640
So 40 caps will cost Rs 640