FactSet interview question

They asked to write java code for some choclates problem