Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

=+Describe the components of this time series.

Answered: 1 week ago