A major grade point average covers only the courses that count toward your major, averaged the same way as any other. The arithmetic is trivial and the input is not, because which courses count is a list your department publishes and it rarely matches the courses you took in that subject.
The list is the whole problem
Departments define the major by requirement rather than by prefix. A course with your subject's code may be an elective that does not count, and a course from another department may be a required cognate that does. Graduate schools and some employers ask for the major average precisely because it filters out everything unrelated, so using the wrong list produces a number that answers a different question.
Doing the arithmetic
Take only the courses on the department's list, multiply each one's grade points by its credit hours, sum, and divide by those credit hours alone. The grade points come from the same institutional table as any other average: 3.7 or 3.67 for an A- depending on where you are, 3.3 or 3.33 or 3.3333 or 3.5 for a B+.
Where repeats and substitutions bite
A substituted course approved by the department usually counts in place of the requirement it replaced, and a repeated course follows the same replace-or-average policy as the cumulative average. Both decisions belong to the department and the registrar rather than to the calculation, and both are worth confirming in writing before quoting a major average on an application.
Questions people ask about how to calculate major gpa
What is a major GPA?
The average of the courses that count toward your major, weighted by credit hours. Which courses those are is defined by the department rather than by the course prefix.
How do I work out my major GPA?
Take the department's list of major requirements, pull those courses from the transcript, and average their grade points weighted by credit hours using your institution's published table.
Why does my major GPA differ from my cumulative?
Because it excludes everything outside the major. A strong performance in the subject and a weaker one in general requirements produces a higher major average, which is why it is asked for.