Motivation on multiple fronts held the attention of the slumping Virginia men’s basketball team before Monday night’s game against visiting Miami.

At the top of the list was sending out the senior class with a victory despite the subdued setting at John Paul Jones Arena. Then came the incentives of remaining in the hunt for a first-place finish in the ACC and ending a three-game slide.

The No. 21 Cavaliers checked all of those boxes with a 62-51 victory, getting a game-high 18 points from Sam Hauser, who was one of four seniors recognized before tip-off, and limiting the severely shorthanded Hurricanes to 21 points and 29.6 percent shooting in the second half.

“Your defense has to hold you in there,” Virginia Coach Tony Bennett said. “Offense can kind of come and go, and it was more about, ‘Are we getting quality looks?’ And that’s all you can ask for — quality looks inside, outside, and are you making them earn their looks, and I thought again to start the second half we did that.”

The win in the penultimate game of the regular season ­secured a double bye in the ACC tournament and keeps Virginia (16-6, 12-4) mathematically alive for the top seed. The second-place Cavaliers, however, would need front-running Florida State to lose out to two teams with a combined eight conference victories.

The more pressing concern — apart from ensuring positive memories for Hauser, Jay Huff, Tomas Woldetensae and walk-on Austin Katstra in their final home game — was recapturing the confidence that comes from winning, which the Cavaliers had not done since Feb. 13.

Virginia used a flurry late in the first half and another midway through the second to gain separation and beat Miami for the fourth straight time. In each of those games, the Cavaliers have not permitted the Hurricanes (7-16, 3-15) to score more than 51 points.

The Cavaliers forced 11 turnovers that led to 13 points and owned a 20-2 advantage in bench points, which was to be expected considering Miami had just six scholarship players available because of what Hurricanes Coach Jim Larrañaga has called catastrophic injuries.

Most notably Miami has been without dynamic senior point guard Chris Lykes, the former Gonzaga (D.C.) star, who has missed all but two games while nursing an ankle ailment. The Hurricanes, losers of six in a row, have been without four primary players for virtually the entire season.

“We talked about Miami being depleted, but those guys are gifted off the dribble at creating shots,” Bennett said. “It never was fully in control, and I thought Sam was really good and did some big stuff.”

Hauser transferred from Marquette to join a senior class that has been vital to Virginia’s transformation into among the most efficient shooting teams not only in the ACC but in the nation, allowing the Cavaliers to thrive on most nights despite taking a step back defensively.

Virginia ranks 26th in the country in adjusted defensive efficiency, according to kenpom.com, but is 16th in adjusted offense and entered the week first in the ACC in overall (48.3) and three-point field goal percentage (39.2). The Cavaliers also lead the conference in free throw shooting (80.1 percent).

Despite just seven points in his home finale, Huff in particular continues to create matchup dilemmas for opposing coaches. At 7 feet, the fifth-year center has made 28 of 68 (41.2 percent) of his three-point attempts, forcing longer defenders at times to stray from the painted area and leave the rim unprotected.

Less interior congestion allows for uncluttered driving lanes that yield layups or opportunities to pass out to open shooters, including Hauser, whose quick release has contributed to making a team-high 57 of 128 three-point attempts.

“It’s been a blessing to come and play for Coach Bennett, and I know he feels the same way about coaching me,” said Hauser, who sat out last season per NCAA transfer rules. “I couldn’t have asked for much more, outside of maybe some fans in the stands, but overall it’s been a great year.”

Woldetensae’s value, meanwhile, became all the more evident in the previous two games, both of which he missed because of contact tracing. His absence left the Cavaliers without one of their top three-point shooters, and they labored from behind the arc in losses to Duke and North Carolina State.

The 6-5 guard from Italy immediately made a three-pointer against Miami for the Cavaliers’ first basket, but sophomore ­Justin McKoy came off the bench to provide the scoring spark that produced a 41-30 halftime lead thanks to a 15-2 run.

McKoy had eight points, including three straight baskets, in Virginia’s highest-scoring first half of the season against an ACC opponent.

“We needed it,” Bennett said of the contributions from reserves. “Very important, and as we talked about Justin, and even Francisco [Caffaro] gave us a good lift getting to the line. It was good to see Tom hit his three, and Casey [Morsell] had a big drive for us. We’ve been playing five guys such heavy minutes, and tonight to be able to go to our bench when that group wasn’t as sharp as it needed to be was very important.”