Question: How do I set up a procedure for a table of data?

Been attempting this question for some time now and can't seem to get it right. 
Each time coming up with a different error.
It's part of our weekly homework, an extention question.
Write a procedure, marks, to take a student’s mark and output the appropriate grade, 
based on the following table:

mark 0-39.99 40-49.99 50-59.99 60-69.99 70+
grade        fail            3rd               lower 2nd         upper 2nd            1st 

marks should output
i) the mark
ii) the grade
iii) and be able to deal with any input, valid or not.

If the mark is within 3 marks of the interval’s upper bound,
    a statement should be added indicating that the grade is '‘borderline'’.

I'm not quite sure how to set up the procedure. I tried doing:
if 0<m<=39.99 then print (m, Fail) fi;
but it returned :
Error, `<=` unexpected
and also help on iii)
many thanks!
Please Wait...