North Carolina State University became the latest college to pivot to online classes, a sign of the challenge facing universities trying to hold onto some semblance of the college experience, with residential life — and student behavior — making it more difficult to prevent the spread of the novel coronavirus.

The school announced Thursday that all undergraduate classes would be held online this fall after clusters of covid-19 cases were found on campus this week, adding to the chaos of students scrambling to adjust to the fast-changing conditions.

The school has had 270 cases among students since March, according to an online dashboard. More than a third of those positive tests were registered Thursday.

At the nearby University of North Carolina at Chapel Hill, which had already announced an abrupt shift to virtual learning this week, the chancellor said undergraduate classes would be canceled Monday and Tuesday to allow students time to move off campus as the number of cases continued to rise. Many were hurrying to pack and find new housing just days after arriving on campus.

And on Thursday night, as positive test results continued to escalate — with 91 new cases Wednesday among students — university officials said they would begin testing at three dorms starting Friday. People living in those buildings would get an email later that night about testing, school officials said, and employees such as housekeepers working there will also be tested.

Given the greater prevalence of coronavirus cases on campus, university officials also announced changes to the way they reported information to the public, with daily updates from clusters at dorms reported on an online dashboard, effective Friday. On Thursday evening, the dashboard had conflicting data, adding to the confusion.

At UNC-Chapel Hill from February to July 20, 113 students had tested positive. Last week, after students returned to campus, 130 more students tested positive.

On Friday, the school said that 88 new cases had been reported among students the day before and that the total number of positive tests since February was 566. One residence alone, Granville Towers, had a cluster of 102 cases.

“It’s been a lot happening in the last couple of days,” said Henry Swift, who had moved into a dorm as a freshman this month and has spent the past few days trying to juggle classes and the prospect of moving back to his parents’ home near Asheville, N.C. “A lot of announcements, a lot of updates,” he said of new clusters of cases and the dwindling availability of quarantine space. “It’s definitely a concern.”

His dorm, Hinton James, was one of those singled out for testing because of the number of positive test results.

School leaders announced Thursday night that they were extending the deadline for students to drop classes through the end of the month, given the turmoil on campus.

The situation was changing quickly at N.C. State, as well. On Wednesday, the school had announced two new clusters at two sorority houses on campus, with a total of 13 cases. On Thursday, Randy Woodson, the chancellor, announced that there were three clusters of cases at the 36,000-student university and that undergraduate classes would be held online-only, beginning Monday.

“In the last two days alone, we’ve identified three COVID-19 clusters in off-campus and Greek Village houses that can be traced to parties and behavior outside of our community standards and the governor’s mandates,” he wrote in a statement announcing the pivot. “We’re seeing significant infections in Greek life, and at this time there have been another seven Greek houses that have been quarantined due to a number of additional positive cases.”

On Thursday evening, the school announced two additional clusters of cases, one at a fraternity house and another at two off-campus homes.

Five hundred students were in quarantine Thursday, either because of positive tests or exposure, Woodson wrote.

Dorms remain open at N.C. State, and students have the option of remaining on campus, according to Mick Kulikowski, a spokesman for the school.

“It remains to be seen how many students leave,” said John Hedlund, a graduate student who was part of a coalition of organizations within the University of North Carolina System advocating against reopening this fall. “If a large number of students remain on campus, even if classes are remote, it’s still going to be a very dangerous, volatile situation.”

Hedlund said he was particularly frustrated that the chancellor’s message seemed to place the blame on students partying. With tens of thousands of students living on campus, the plan was untenable from the start, he said. “This was bound to fail.”

University of North Carolina System President Peter Hans issued a statement Thursday saying that each institution had prepared over the spring and summer with guidance from public health officials. “This hard work is being undermined by a very small number of students behaving irresponsibly off campus,” he said, “which unfairly punishes the vast majority of their classmates who are following the rules.”

Hedlund said that without discounting the need for social distancing, “the blame for the outbreaks that have occurred on campus and the need to so rapidly switch to remote learning is on the UNC administration and the board of governors.”

At Johns Hopkins University, which pivoted to online instruction for undergraduates earlier this month and urged students not to return to campus, spokeswoman Karen Lancaster said administrators expect to have fewer than 100 undergraduates living on campus when classes start Aug. 31, but they don’t yet know how many students plan to move into apartments near campus.

Some people are upset that they signed leases and found out in early August that classes would be held online, said Sam Mollin, student body president at Hopkins. But the university acknowledged the sudden shift would create a financial hardship for many students and took steps to address that, such as discounting fall tuition and increasing financial aid. “I think they’ve done better than other universities.”

Michigan State University announced Tuesday that most classes would be taught remotely.

And some schools began penalizing students who didn’t follow guidelines for social distancing.

Virginia Tech imposed an interim suspension on seven students Thursday after local law enforcement reported a large, disruptive gathering of people not wearing masks or distancing.

At Purdue University, 36 students received interim suspensions after a party this week. The school has been clear about the rules students must follow on campus this fall, Katie Sermersheim, associate vice provost and dean of students, said in a statement. “Unfortunately, everything we have done — the months of planning to give our students the opportunity to continue their educational pursuits in person — can be undone in the blink of an eye — with just one party or event that does not follow the rules and guidelines.”

On Monday, UNC-Chapel Hill, the state flagship school with 30,000 students, had abruptly changed to virtual instruction after testing revealed the rapid spread of the coronavirus.

It was a week after classes had started, leaving many students who had just unpacked scrambling to find new housing or move back home.

The school began the semester at 60 percent capacity in its dorms, an effort to reduce the spread of the coronavirus but quickly responded after finding increased cases among students.

The university has asked students to move back home if they are able to but is making exceptions for some students.

Since Monday afternoon, more than 2,800 students asked to cancel their housing contracts, and more than 2,500 appointments to move out have been scheduled.

By Thursday, occupancy in on-campus housing had dropped to 51 percent, according to a campus dashboard of coronavirus-related data.

When the switch to virtual classes was announced, “it was widespread chaos,” said Lamar Richards, a sophomore from Columbia, S.C.

“Everyone kind of had in their mind that this might happen eventually,” he said. “But students were not prepared to be told, ‘You need to go home,’ so soon after getting here. Students are feeling lost, without hope,” and some are saying they will take the semester or the year off.

Many needed financial help to rent moving vans, and to pay for gas or for plane tickets home, he said. Richards, who chairs the Commission on Campus Equality and Student Equity, a student group, said a fundraiser that began Wednesday night at 10 p.m. had raised nearly $7,000 less than 24 hours later. There were multiple efforts underway to help students pay for the sudden move, he said.

“It’s starting to feel like a ghost town,” said Stefano Dongowski, a 17-year-old freshman, with students moving out of his dorm at UNC. One of his friends had lugged a couch into the dorm, only to have to drag it back out. Others had gone all-out decorating their rooms, only to dismantle it all. His parents are coming Saturday to drive him home to Wilmington, N.C., he said, and he got tested for the coronavirus Wednesday as a precaution.

He didn’t think campus was safe, but two of his classes — Italian and math — were being held in-person, so he had moved into the dorm.

“It’s really frustrating,” he said. “I could have just stayed home.”

Nick Anderson contributed to this report.