Question: Checker guidelines: for compatibility with the checker, the struct array must be called students, and the names of the fields must be Name, Credits, and

Checker guidelines: for compatibility with the checker, the struct array must be calledstudents, and the names of the fields must beName,Credits, andMajor, with the first letter capitalized. The Name, Credits, and Major fields MUST BE COLUMN VECTORS, NOT ROW VECTORS.

The trickiest part is getting the letter grades into a column vector field. Try something like this:

students(sheet).Grades = [txtData{2:end, 2}]

Here's the function for reference:

function gpas = GPA(Student) %Declare the variables totalGrades=0; totCredits=0; totMajorGrades=0; totMajorCredits=0; %Use a for loop, to calculate the total credits, total grades, %total major grades, and total major credits for i=1:length(Student.Grades) %Check the student grade is equal to A if (Student.Grades(i)=='A') % calculate the total grades and credits totalGrades=totalGrades+4*Student.Credits(i); totCredits=totCredits+Student.Credits(i); if(Student.Major(i)) % calculate the total major grades and major credits totMajorGrades=totMajorGrades+4*Student.Credits(i); totMajorCredits=totMajorCredits+Student.Credits(i); end %Check the student grade is equal to B elseif (Student.Grades(i)=='B') % calculate the total grades and credits totalGrades=totalGrades+3*Student.Credits(i); totCredits=totCredits+Student.Credits(i); if(Student.Major(i)) % calculate the total major grades and major credits totMajorGrades=totMajorGrades+3*Student.Credits(i); totMajorCredits=totMajorCredits+Student.Credits(i); end %Check the student grade is equal to C elseif (Student.Grades(i)=='C') % calculate the total grades and credits totalGrades=totalGrades+2*Student.Credits(i); totCredits=totCredits+Student.Credits(i); if(Student.Major(i)) % calculate the total major grades and major credits totMajorGrades=totMajorGrades+2*Student.Credits(i); totMajorCredits=totMajorCredits+Student.Credits(i); end %Check the student grade is equal to D elseif (Student.Grades(i)=='D') % calculate the total grades and credits totalGrades=totalGrades+Student.Credits(i); totCredits=totCredits+Student.Credits(i); if(Student.Major(i)) % calculate the total major grades and major credits totMajorGrades=totMajorGrades+Student.Credits(i); totMajorCredits=totMajorCredits+Student.Credits(i); end %Check the student grade is equal to F elseif (Student.Grades(i)=='F') % calculate the total credits totCredits=totCredits+Student.Credits(i); if(Student.Major(i)) % calculate the total major credits totMajorCredits=totMajorCredits+Student.Credits(i); end end end

%calculate the gpas gpas=[totalGrades/totCredits totMajorGrades/totMajorCredits]; end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!