If a 12 oz bottle of shampoo lasted for 16 weeks, we have a ratio of 12:16 which can be shortened to 3:4.
Now if we have 18 oz bottle we know that it's 1/2 more than 12 oz bottle, so the ratio will be also 1/2 more. So if it was 12:16, the new ratio will be:
12 + (1/2 * 12) : 16 + (1/2 * 16)
12 + 6 : 16 + 8
18 : 24
It means that 18 oz bottle should last for 24 weeks. Of course the ratio has to stay the same in its lowest form in both situations and as 18:24 can be shortened to 3:4, it proves it's correct :)