I have a matlab homework assignment to build a grade calculator in matlab.First time coding and in need of some help!

조회 수: 9 (최근 30일)
I need the program to take a range of inputs in matrix form and return a letter grade. 0-59.99=F 60-69.99=D, etc. The program needs to discard negative grades, and calculate all of the following:
  • ○ Numeric mean (class average)
  • ○ Average letter grade for the class
  • ○ Standard deviation of the grades
  • ○ Highest numeric grade
  • ○ Lowest numeric grade
Any help would be appreciated: here is what I have thus far:
enter=1;
grade=[];
t=1;
while enter==1
grades(t) = input ('Please enter a grade');
if grades(t) < 59.99 && grades(t) >= 0
disp ('F')
elseif grades(t) >= 60 && grades(t) <= 69.99
disp ('D')
elseif grades(t) >= 70 && grades(t) >= 79.99
disp ('C')
elseif grades(t) >= 80 && grades(t) >= 89.99
disp ('B')
elseif grades(t) >= 90 && grades(t) >= 100
disp ('A')
if grades(t) <= 0 disp (N/A)
end
  댓글 수: 3
Brian Mabe
Brian Mabe 2016년 9월 2일
편집: Brian Mabe 2016년 9월 2일
The user will be entering grades one at a time. After they have no more grades left to input, they will enter "0". Then the code should hold onto the set of numeric entries, store them as a matrix, and express the average as a letter grade equivalent.
I also need to write a second script to calculate mean, median, mode, standard deviation etc., HOWEVER, I am not allowed to use operators like std.
Thank you, in advance, for your advice!
Nstaub
Nstaub 2016년 9월 2일
I would suggest to be careful with your input because user can input a string which will mess up your tests. Also I prefer fprintf to disp function as you get more control on the string output. my 2 cents

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by