Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Help me out finding errors

1 Ansicht (letzte 30 Tage)
Raed Noor
Raed Noor am 11 Nov. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hey there
I have a homework to calculate the total grade on some quizzes. I know there are some error, could you please help me out finding and fixing them??
A = cell(20,7);
i = 1;
x = input ('Enter the student''s name ( or to termate ):','s');
while(~strcmp(x,'0'))
A{i,1} = x;
A{i,2} = input('Enter the grade for the exam 1 ( out of 20) ');
A{i,3} = input('Enter the grade for the exam 2 ( out of 20) ');
A{i,4} = input('Enter the grade for the exam 3 ( out of 20) ');
A{i,5} = input('Enter the grade for the exam 4 ( out of 20) ');
A{i,6} = A{i,2};
for j = 2:5
A{i,6} = A{i,6} + A{i,j};
end
z = floor(A{i,6}/10);
if (z < 6)
A{i,7} = 'F';
elseif (z < 7)
A{i,7} = 'D';
elseif (z < 8)
A{i,7} = 'C';
elseif (z < 9)
A{i,7} = 'B';
else (z < 9)
A{i,7} = 'A';
end
x = input ('Enter the student''s name ( or to termate ):','s');
i = i+1
end
I’m receiving this error!
Enter the grade for the exam 1 ( out of 20) Attempt to execute SCRIPT test as a function: /MATLAB Drive/test.m
Error in HM11 (line 8) A{i,2} = input('Enter the grade for the exam 1 ( out of 20) ');
  4 Kommentare
Walter Roberson
Walter Roberson am 12 Nov. 2019
Bearbeitet: Walter Roberson am 12 Nov. 2019
What about the fprintf() ? Your question does not mention fprintf()
fprintf('Student name: "%s", grade: "%s"\n', A{i,1}, A{i,7});
By the way, your code is very trusting that none of the responses will be nan or infinite, and that no-one will have a perfect score...And have a close close look at what you are comparing each value to.
Raed Noor
Raed Noor am 12 Nov. 2019
It's my prof's and he want's me to fix it. If it was mine, it'll be way to sampler. I hope it works now. Thank!

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by