IN MATLAB
Graduating with Honors. In an effort to recognize students, the GPA honor system of the Universidad del Pueblo Borincano, highest prestige in the country, students are recognized if their GPA is in the range:
Honor Required GPA (Survivor) 1.00<=GPA<2.00 (Overcoming ) 2.00<=GPA<3.00 (Honor) 3.30<=GPA<3.40 (High Honor) 3.40<=GPA<3.90( Maximum Honor) 3.90<=GPA<=4.00
NOTE: To produce a fake gpa array with N records add to your program the lines below. A good idea is to run these lines separately before anything else to understand how they work. Search the internet for the meaning of rand (for random) and round (for rounding) matlab functions.
Write a program to count the number of students honored in each category. Count also the total number of students honored.
% a[gpa lower bound]; b[gpa upper bound]; N[number of records]
a=0; b=4.0; N=13324; gpa=round((b-a).*rand(1,N)+a, 2) % number of decimals
Expert Answer
Solution=====================
Note:in question overcoming category ends with <3.0, but Honor Category starts with 3.30, creating a gap, which will make students with 3.10, 3.25.. or similar grades miss out any category
% a[gpa lower bound]; b[gpa upper bound]; N[number of records]
a=0; b=4.0; N=13324; gpa=round((b-a).*rand(1,N)+a, 2); % number of decimals
%Honor Required GPA (Survivor) 1.00<=GPA<2.00 (Overcoming ) 2.00<=GPA<3.00 (Honor)
%3.30<=GPA<3.40 (High Honor) 3.40<=GPA<3.90( Maximum Honor) 3.90<=GPA<=4.00
Survivor=0;
Overcoming=0;
Honor=0;
High_Honor=0;
Maximum_Honor=0;
Total_honored=0;
for idx = 1:numel(gpa)
GPA=gpa(idx);
if GPA >=1 && GPA < 2;
Survivor=Survivor+1;
elseif GPA >=2 && GPA < 3;
Overcoming=Overcoming+1;
elseif GPA >=3.30 && GPA < 3.40
Honor=Honor+1;
elseif GPA >=3.40 && GPA < 3.90
High_Honor=High_Honor+1;
elseif GPA >=3.90 && GPA < 4
Maximum_Honor=Maximum_Honor+1;
end
end
Total_Honored=Honor+High_Honor+Maximum_Honor;
fprintf(‘Survivor Category Count: %dn’,Survivor);
fprintf(‘Overcoming Category Count: %dn’,Overcoming);
fprintf(‘Honor Category Count: %dn’,Honor);
fprintf(‘High Honor Category Count: %dn’,High_Honor);
fprintf(‘Maximum Honor Category Count: %dn’,Maximum_Honor);
fprintf(‘Total Honored: %dn’,Total_Honored);
Output================