use unitary method

e.g.

let cost of 5 box is 25 cents .

therefore cost of 1 box =25/5 cents =5 cents

and cost of 30 such boxes = 30 *(5) = 150 cents

total cost of x apples = b cents

therefore cost of one apples = b/x cents

now you can calculate cost of 2 apples or 9 apples or y apples

cost of y apples = yb/x cents