SWI prolog and java programming (cut deck problem)

SWI prolog and java programming (cut deck problem). SWI prolog and java programming (cut deck problem). I need code solution for the cut decking predicate in the attached document.
The solution code needs to be written in two languages, the first is SWI Prolog and the second is java.
All the instructions are in the document. document your code and provide explanation of what your code doing.

SWI prolog and java programming (cut deck problem)

SWI prolog and java programming (cut deck problem)