“Life is not fair,” said Rashema Melson, who lost her father when she was 7 months old. “But despite that harsh reality, you must keep striving for success.” (Marvin Joseph/The Washington Post)

Rashema Melson, the valedictorian of Anacostia High School, told her fellow graduates Wednesday that her two years at the school had been “wonderful.” They definitely ended well, with the track star at the top of her class and headed to Georgetown University on a full scholarship.

But those years couldn’t have been easy — Melson has lived during that time in a D.C. homeless shelter, sharing a single room with her mother and two brothers.

“Life is not fair,” said Melson, whose father was killed when she was 7 months old. “But despite that harsh reality, you must keep striving for success.”

In a Howard University auditorium packed with cheering family members, Melson marched in with the Class of 2014 and took the stage with D.C. Council member and Democratic mayoral candidate Muriel Bowser and Schools Chancellor Kaya Henderson.

The upbeat valedictorian thanked a long list of coaches, teachers and counselors for her long-shot achievements. “These educators actually care about our well-being,” she said.

Melson, 18, exhorted her classmates — to raucous cheers — to “beat the odds and let the sun shine.”

In a basement packed with red-gowned graduates before the commencement ceremony, Melson said she was ready for the rush of graduation to fade, along with the spotlight that has come with her success. She has a final summer before starting classes at a school that is eight miles — and a wide world — away from Anacostia High on Sixth Street SE. The Georgetown scholarship includes room and board.

“I’m ready to do it and get on with everything,” Melson said. “I didn’t expect all this attention.”

Melson lives in the same city facility where 8-year-old Relisha Rudd lived before she disappeared in March. There have been calls to close the shelter, which is housed in the former D.C. General Hospital. Melson said she wore headphones to study in the crowded, often chaotic environment.

“It’s really impressive that someone could zone everything out, the fact that her dad was killed, that she is surrounded by the hood every day,” said Juan Gonzalez, Melson’s writing teacher.

Melson was clearly driven to succeed, he said. Even his 12th-grade Advanced Placement composition class didn’t satisfy her hunger for practice. “When I didn’t give homework, she would say, ‘Mr. Gonzalez, what else can I do to improve?’ ”

While Melson’s scholarship stood out, her circumstances are not that unusual in a school that serves one of the poorest sections of the city. The school’s second-highest academic achiever, salutatorian Justina Lloyd, has also lived in a shelter, Gonzalez said.

“This is all of our kids,” Gonzalez said. “They’ve all achieved something by getting to graduation. These two have to deal with timing a shower in the shelter so they can be on time to school. I couldn’t do it.”

It was Lloyd who introduced the commencement speaker, columnist Julianne Malveaux, who in turn marveled at two of the graduates on the stage with her.

“They are flying from homeless to opportunity!” she said.