**Fruit A:**

Profit per $1 of investment is `100/300=$1/3`

Also for $1 you can buy `1/300`kg

**Fruit B:**

Profit per $1 of investment is `200/800=$1/5`

Also for $1 you can buy `1/800`kg

So you need to maximize function `p`, that is profit, under certain conditions:

`p=1/3x_A+1/5x_B` (1)

`1/300x_A+1/800x_Bleq500` (2)

`x+yleq240000` (3)

`x,ygeq0` (4)

**(1)** - profit from buying fruit A and B for `x_A` and `x_B` dollars respectivly.

**(2)** - this condition says we must buy 500kg of fruit

**(3)** - this condition says we must spend $240000

**(4)** - this condition says we can't spend negative amount of money

We need to maximize `p`. We can do that by looking what is the value of `p` in vertices of polygon given bx conditions (2)-(4). In other word we are looking the value of `p` in intersections of lines given by conditions (2)-(4).

This is usually done by *simplex method* but thic case is very simple so you can check all vertices. I will tell you that your solution at the intersection of coditions (2) and (3) so that means you need to buy

**320kg** (spend `x_A=$96000` ) and **180kg** (spend `x_B=$144000` ) so your profit is `p=$60800`.

Fot more on linear programming see the links below or some literature e.g. *Bertsimas D., Introduction to linear optimization*.