A new Monte Carlo code named CEARCPG has been developed to generate both the normal and coincidence library spectra for the prompt-gamma-ray neutron activation analysis (PGNAA) inverse analysis problem. A new algorithm for sampling the neutron-induced prompt gamma rays has been developed and implemented within the CEARCPG code, making it possible to calculate the coincidence spectrum by the Monte Carlo method. Compared to the previous code CEARPGA II, which was for normal PGNAA, several improvements have been made, including implementation of the coincidence spectrum simulation and elimination of the "big weight" problem by implementing a new algorithm to generate prompt gamma rays. Several experiments have been carried out to benchmark the new CEARCPG code, and simulation results are also compared with MCNP5 calculations.