Write a computer program that determines how many grades are between 0 and 19

4 Ansichten (letzte 30 Tage)
A list of 30 exam scores is: 31, 70, 92, 5, 47, 88, 81, 73, 51, 76, 80, 90, 55, 23, 43, 98, 36,87, 22, 61, 19, 69, 26, 82, 89, 99, 71, 59, 49, 64 Write a computer program that determines how many grades are between 0 and 19, between 20 and 39, between 40 and 59, between 60 and 79, and between 80 and 100. The results are displayed in the following form: Grades between 0 and 19 2 students Grades between 20 and 39 4 students Grades between 40 and 59 6 students and so on. (Hint: use the command fprintf to display the results)
  3 Kommentare
JJJ NNN
JJJ NNN am 21 Apr. 2016
Bearbeitet: James Tursa am 13 Okt. 2016
this is my code but i dont know what to do after
x=[ 31 70 92 5 47 88 81 73 51 76 80 90 55 23 43 98 36 87 22 61 19 69 26 82 89 99 71 59 49 64];
y1=(x>0 & x<=19);
c1=x(y1)
d1=length(c1)
disp(d1)
Joshua Magno
Joshua Magno am 13 Okt. 2016
Bearbeitet: Joshua Magno am 13 Okt. 2016
I=[31,70,92,5,47,88,81,73,51,76,80,90,55,23,43,98,36,87,22,61,19,69,26,82,89,99,71,59,49,64];
a=sum(I>=0 & I<=19);
fprintf('The grades between 0 and 19 is %1.0f students.\n',a)
b=sum(I>=20 & I<=39);
fprintf('The grades between 20 and 39 is %1.0f students.\n',b)
c=sum(I>=40 & I<=59);
fprintf('The grades between 40 and 59 is %1.0f students.\n',c)
d=sum(I>=60 & I<=79);
fprintf('The grades between 60 and 79 is %1.0f students.\n',d)
e=sum(I>=80 & I<=100);
fprintf('The grades between 80 and 100 is %2.0f students.\n',e)

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Jos (10584)
Jos (10584) am 21 Apr. 2016
help numel
help for
help if
or
help histc

Image Analyst
Image Analyst am 21 Apr. 2016
Try histogram() or histcounts():
edge = [0, 19.5, 39.5,,,,,, etc.
counts = histcounts(.........
Two lines of code. One or two more if you want to use fprintf() to print results to the command window
fprintf('%d\n', cou..................

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by