Program 7
Program 7
7. Design and develop a Java program for the fruit market problem. The farmer will be able to
produce different types of fruits (apple, orange, grape, and watermelon), and put them in the
market to sell. The market has limited capacity and farmers have to stand in a queue if the
capacity is exceeded to sell their fruits. Consumers can come to the market any time and
purchase their desired fruits; and if the fruits they want to buy runs out, they are willing to
wait until the supply of that kind is ready. Examine and formulate an approach to address this
problem and implement the same using Java constructs for programming.
import java.util.LinkedList;
import java.util.Random;
class Market
{
LinkedList<String> Fruitslist = new LinkedList<>();
int capacity=10;
String[] fruits = {"orange","grapes","apple","mango","watermelon"};
Output