The sad thing about farmers is that they don’t usually get a chance to price their fruits and vegetables, unless you mean the ones at the Farmer’s Market. The distributors, who have a wide variety of farmers from which to choose, often set the prices, and the farmer can either take it (sometimes earning less than the cost of production), or leave it (and end up holding a perishable commodity that they’ll get absolutely nothing for). If they have the nerve to ask even a couple cents more for their produce, the distributor will just pass on by and go to the next farmer.
As far as the ones at the Farmer’s Market (or who sell more directly to consumers), I’m sure it’s a combination of seeing what the other farmers are asking, what they think the market can bear (especially if it’s out of season or otherwise a novelty), and how much it cost to produce (plus enough profit to keep going).