Can I take a class three times in order to get the required grade?
I repeated a class and still haven't gotten a B in it. Can I take it a third time?
Repeating a course for a second time is not prohibited. However, you should be aware that each course attempt will be reviewed as part of your application for the major. If the Admission Committee finds that you have consistently taken your CS and/or math courses multiple times in order to earn the B grade required for admission, this will weaken your application substantially.
It is highly recommended that you contact your advisor to discuss any other options you may have rather than just enrolling for the class for a third time. The advisor will be able to gauge how this repeat, within the context of your entire academic record, will affect your admissability.