Write a computer program that determines how many grades are between 0 and 19
Afficher commentaires plus anciens
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 commentaires
Azzi Abdelmalek
le 21 Avr 2016
This looks like a homework. Show us your code, and the problems you encountered.
JJJ NNN
le 21 Avr 2016
Modifié(e) : James Tursa
le 13 Oct 2016
Joshua Magno
le 13 Oct 2016
Modifié(e) : Joshua Magno
le 13 Oct 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)
Réponses (2)
Jos (10584)
le 21 Avr 2016
help numel
help for
help if
or
help histc
Image Analyst
le 21 Avr 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..................
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!