Difficulties abound here. Show us some code, so we can better direct you. If you can specify the input better, and give examples of input/output,we can write something up.
Are these statements expected to appear together? Are they sprinkled throughout unformatted text?
-QM
--
Quantum Mechanics: The dreams stuff is made of