Should I quit the PhD program?
Don't do anything without more information. In particular:

Why were your papers rejected? Was it because of some analysis you did not do? Was the entire approach bad? Was it correct but not interesting enough for the journal? These rejection reasons all reflect differently on your ability as a researcher. Remember as well that your supervisor was almost surely heavily involved in the paper, so at some level it's not just you being rejected. If for example the entire approach was bad, then your supervisor is just as responsible (arguably even more responsible, since they're supposed to be guiding you).
If you quit, what can you do? Don't just say &quot;I can still find a good job&quot;. Make sure you know what kind of job you can find. Look at your local job portals and see what's out there for people with your qualifications. You may have a CS Master's degree, but can you program in the languages that people want, or perform the types of analyses that is asked for?

From the answers to these two questions you can make a much better-informed decision. If your conclusion is you are an idiot and not suitable for pursuing a PhD degree (are you sure? I would at least talk to your advisor to confirm that you are underperforming), then quitting makes more sense. On the other hand, if you quit now when you're actually overperforming your advisor's expectations, then you'd have metaphorically shot yourself in the foot.
Get the information first, sleep on it (so you don't make emotionally charged decisions), talk to your advisor, and then make a decision. Either way it'll be a life-changing moment.