code is running but nothing pops up in my workspace?

2 views (last 30 days)
in my command window it says
lab4
Enter a score (-1 to stop):
ctA = 0; %fill this with the quantity of A grades
ctB = 0; %fill this with the quantity of B grades
ctC = 0; %fill this with the quantity of C grades
ctD = 0; %fill this with the quantity of D grades
ctF = 0; %fill this with the quantity of F grades
d = input('Enter a score (-1 to stop): ');
scores = []; %empty array where values are stored
while d ~= -1
scores = [scores d]
d = input('Enter a score (-1 to stop): ');
end
for i =1:length(scores) % length of value i
if (scores(i) >= 90) % input if value is less than or equal to 90
ctA = ctA + 1 % how many As
scores = [scores, i]; % store the # of As in to score
elseif (scores(i) >=80) %input if value is less than or equal to 80
ctB = ctB +1 % how many Bs
scores= [scores i]; %store the # of Bs in to score
elseif (scores(i) >=70) %input if value is less than or equal to 70
ctC = ctC + 1 % how many Cs
scores= [scores i]; %store the # of Cs in to score
elseif (scores(i) >=60) %input if value is less than or equal to 60
ctD = ctD + 1
scores= [scores i];
elseif (scores(i) <60)
ctF = ctF + 1
scores= [scores i];
end
end
%displaying grades
disp("# of As: " + ctA);
disp("# of Bs: " + ctB);
disp("# of Cs: " + ctC);
disp("# of Ds: " + ctD);
disp("# of Fs: " + ctF);
  2 Comments
Aman Vyas
Aman Vyas on 7 Oct 2020
Hi,
You can try relaunching or matlab again or try re-running as this script runs perfectly fine for me.
I am attaching the screenshot that i obtained on running your script. Take a look at the output I obtained:
purposes only. Not for sale.
>> ml_a
Enter a score (-1 to stop): 45
scores =
45
Enter a score (-1 to stop): 22
scores =
45 22
Enter a score (-1 to stop): 33
scores =
45 22 33
Enter a score (-1 to stop): -1
ctF =
1
ctF =
2
ctF =
3
# of As: 0
# of Bs: 0
# of Cs: 0
# of Ds: 0
# of Fs: 3
ml_a
>>
Hope it helps !

Sign in to comment.

Answers (0)

Categories

Find more on Transmissions in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!