Thanks for the replies. From what I understand, at my university you can only repeat a course if you get a D or below, so I'm not sure if I can repeat the course at my university but I'll look into it.
As a follow-up question, if you do well at a highly regarded master's program, how much do undergraduate grades factor into the admission committee's decision? I come from a Top 50 university, with mostly A's in my math and economics courses.