how can ı add the given instruction to my program?
Mostrar comentarios más antiguos
clc; clear;
% Student numbers:
stu_nums = 20200001:20200102;
%% Randomly generated marks:
for i = 1:length(stu_nums)
stu(i).exam1 = randi([0 100]) ;
stu(i).exam2 = randi([0 100]) ;
stu(i).lab = randi([0 100]) ;
stu(i).fin_exm = randi([0 100]) ;
stu(i).fin_grd = round(stu(i).exam1*0.25 + stu(i).exam2*0.2 + stu(i).lab*0.15 + stu(i).fin_exm*0.4) ;
end
%% Finding non-failing students:
S = 0 ;
for i = 1:length(stu_nums)
if stu(i).fin_exm < 35 || stu(i).lab < 10
stu(i).let_grd = 'FF' ;
else
S = [S stu(i).fin_grd] ;
end
end
%% Mean of non-failing students' marks and standard deviation:
S(1) = [] ;
avg = mean(S) ;
st_dev = std(S) ;
%% Grade range:
CC = avg ;
% Starting points for upper grades:
CB = round(CC+st_dev/2) ;
BB = round(CB+st_dev/2) ;
BA = round(BB+st_dev/2) ;
AA = round(BA+st_dev/2) ;
% Ending points for lower grades:
DC = round(CC-st_dev/2) ;
DD = round(DC-st_dev/2) ;
FD = round(DD-st_dev/2) ;
FF = round(FD-st_dev/2) ;
%% Grade each student:
for i = 1:length(stu_nums)
if stu(i).fin_grd <= FF
stu(i).let_grd = 'FF' ;
elseif stu(i).fin_grd > FF && stu(i).fin_grd <= FD
stu(i).let_grd = 'FD' ;
elseif stu(i).fin_grd > FD && stu(i).fin_grd <= DD
stu(i).let_grd = 'DD' ;
elseif stu(i).fin_grd > DD && stu(i).fin_grd <= DC
stu(i).let_grd = 'DC' ;
elseif stu(i).fin_grd > DC && stu(i).fin_grd < CB
stu(i).let_grd = 'CC' ;
elseif stu(i).fin_grd >= CB && stu(i).fin_grd < BB
stu(i).let_grd = 'CB' ;
elseif stu(i).fin_grd >= BB && stu(i).fin_grd < BA
stu(i).let_grd = 'BB' ;
elseif stu(i).fin_grd >= BA && stu(i).fin_grd < AA
stu(i).let_grd = 'BA' ;
elseif stu(i).fin_grd >= AA
stu(i).let_grd = 'AA' ;
end
end
this is my computer program which would read these data and calculate the total grade for each student.
After the letter grades are calculated the program would ask the user what type of information is asked for. The program should ask the user whether the user wants to see overall grade distribution or grade information for an individual. Here my program should watch for invalid input. If the user enters an invalid input, the program should warn the user and ask for the input again until the user enters a valid input. In this phase the program should NOT stop until the user enters a valid input.
how can ı do that?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!