The logic used by the machines, It differentiated the fruits with the help of colour. So the weighing scale that would weigh only cherries and strawberries only weighed what was red. So the man peeled it and then weighed the fruit. Since it is red inside the machine weighs it and marks it at the price of cherries
The man was clever he somehow figured out that the machine works on the logic and weighs only red color fruits. Then he cuted the melons and so the machine thinks of them as cherries and apple.