Kindly explain what is the logic of the program.I will try to implement the logic using JAVA.
Tank You