Calculate your GPA this semester: -Write a function makesemester.m that creates
ID: 3633561 • Letter: C
Question
Calculate your GPA this semester:-Write a function makesemester.m that creates the structure mysemester with the following fields: lastname, firstname, class, credit and grade.
-Write a program mysemester.m that uses the function makesemester.m to create a structure array myfall2011 with the fields mentioned above.
(The 1st element in the array includes your 1st class with the current grade, 2nd element includes your 2nd class with current grade and so on.)
- For exlample for the 1st element:
myFall2011(1) = makesemester('Jones','David','ENGR1371',3,'B');
- Include in your program the commands to calculate your GPA
Explanation / Answer
Dear, The makesemester.m file is function makesemester() mysemester = struct('lastname',{}, 'firstname', {},'class',{},'credit',[],'grade',{}) mysemester; end ----------------------------------------------------------------------------------------------------- The mysemester.m file is function mysemester() makesemester(); myfall08=struct([]); myfall08(1).lastname='John'; myfall08(1).firstname = 'David'; myfall08(1).class='ENGR1371'; myfall08(1).credit=3; myfall08(1).grade='B'; myfall08 disp('GPA calculation:') if myfall08(1).credit==3 disp(myfall08(1).credit) disp('Good') end end --------------------------------------------------------------------------------------------- OutPut: >> mysemester() mysemester = 0x0 struct array with fields: lastname firstname class credit grade myfall08 = lastname: 'John' firstname: 'David' class: 'ENGR1371' credit: 3 grade: 'B' GPA calculation: 3 Good Hope this would helps you
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.