What can students do if a professor penalizes an entire class because one student cheated on an exam?
The described event does taint the exams given by everybody in the room. Even if they didn't mean to cheat. Sorry.

What to do in such a case is a hard question. It ranges from doing nothing this time, but e.g. collecting cellphones and such next exam; just punishing the careless cheater (if caught); grade the affected question(s) for less maximal grade (or even not grade them at all, leaving them for a separate evaluation); or even repeat the exam.