Elon Musk unveiled SpaceX’s seven-seat Dragon V2 spacecraft, in Hawthorne, Calif., on May 29, 2014. (Robyn Beck/AFP/Getty Images)

During her four years in high school, Annie Thomas helped build a six-foot, 120-pound robot, competed on the swimming team, and earned a 4.37 cumulative grade-point average.

But the biggest challenge for the 17-year-old at Thomas Jefferson High School for Science and Technology came during her senior year, when she had the third complete reconstructive surgery on her hips in two years.

“Missing a whole month of senior year was disappointing,” said Annie, who walked the halls on crutches as she recovered from the operation to address arthritis, which she has had since age 10.

But she persevered through pain and discomfort, and her grit became apparent to executives at the aerospace engineering corporation SpaceX, which awarded the Great Falls, Va., student a $3,000 scholarship as a young woman interested in a career in science, technology, engineering and math, known as the STEM disciplines. SpaceX officials said this is the first high school scholarship that Elon Musk’s company has awarded.

“Engaging and inspiring more young women to pursue these fields will help us continue to push the frontiers of knowledge and discovery, and is critical to our economic future as a nation,” SpaceX President Gwynne Shotwell said in a statement.

In Annie’s application for the scholarship, she wrote that she thinks she’s a better person as a result of the hardship she has faced through her medical procedures. She had to give up her spot on the crew team and will undergo more surgery at the end of June.

“Throughout these health issues, I have never considered giving up or feeling sorry for myself, something I am proud of,” she wrote. “In spite of the pain, I have continued to have a cheerful, positive outlook.”

The SpaceX scholarship will be awarded annually to a female senior at TJ, as the Northern Virginia magnet school is known. SpaceX officials said that on top of the money, Annie is invited to visit the company’s factory and meet with women who work at SpaceX, a chance for her to explore mentoring opportunities.

Annie said that she applied for the scholarship because it promotes women in the STEM fields.

“There needs to be more women in STEM, because so far it’s been leaving half of the population untapped,” she said. At SpaceX, based in Hawthorne, Calif., about 12 percent of the workforce is made up of women, executives said.

Annie plans to study computer engineering at the University of Illinois at Urbana-Champaign in the fall.

At TJ, she built robots and designed and constructed the electronic system for the school’s robotics team, Carpe Robotum.

“I know that my attitude and ability to work hard have shown me that I’ll be able to have a happy and successful life,” she wrote in her essay. “Not many 17-year-olds can say that [they] are better for having four complete hip reconstructive surgeries — but I believe I am a better person as a result.”

Despite her medical setbacks, another victory will come Saturday, Annie said. She plans to walk across the stage without crutches to receive her diploma.