Write a computer program that determines how many grades are between 0 and 19
Mostrar comentarios más antiguos
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 comentarios
Azzi Abdelmalek
el 21 de Abr. de 2016
This looks like a homework. Show us your code, and the problems you encountered.
JJJ NNN
el 21 de Abr. de 2016
Editada: James Tursa
el 13 de Oct. de 2016
Joshua Magno
el 13 de Oct. de 2016
Editada: Joshua Magno
el 13 de Oct. de 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)
Respuestas (2)
Jos (10584)
el 21 de Abr. de 2016
help numel
help for
help if
or
help histc
Image Analyst
el 21 de Abr. de 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..................
Categorías
Más información sobre Get Started with MATLAB 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!