LAB #4 RUBRIC:
8 points total for the first three
1a-c)There are a WIDE variety of answers for this. For all of them:
-Loop terminates (1 point)
-Syntax is correct (1 point)
-Termination condition is correct (2 points)
-If it's only slightly off then only -1 point. Use your best judgement.
-Each iteration adds the current number to whatever is used as an accumulator (2 points)
-By the end of the code, sum is correct (2 points)
-If it's off by some constant amount, then only -1 point.
-If there is a solution for which sum is always correct, then give full credit
(except for any points lost for syntax)
a.)
i = m;
while( i <= n ) {
sum = sum + i;
i++;
}
b.)
i = m;
do {
sum = sum + i;
i++;
} while( i <= n );
c.)
for( i = m; i <= n; i++ ) {
sum = sum + i;
}
2.) Should be sigma (variable = m below the sigma and n above the sigma and the aforementioned variable to the right of the sigma). I suspect there are other ways of doing this too; anything that works gets full credit. Different possible grades for this question:
-5 pts (they used summation notation and it's correct)
-2 pts (they used summation notation but it's not correct)
-1 pt (it's correct but they didn't use summation notation - I'm not sure what this would look like but it's in the realm of possibility)
3.) Again, there are a LOT of possible answers for this. My own answer:
while( s[ length ] != '\0' ) {
length++;
}
If they called a built-in length function (i.e. strlen), then only give (2 pts)
Otherwise, here are some grading guidelines:
-Used a loop (2 pts)
-Loop terminates (2 pts)
-Syntax is correct (2 pts)
-If it's one minor thing then only 1 point off. But if it's bigger take off the
whole two points.
-Each iteration of the loop adds to some accumulator (2 pts)
-If there is a solution that doesn't do this but length is still correct by
the end of the code, then still give these two points. I don't think it's
possible but I mention this just in case.
-Length is correct by the end of the code (7 points)
-It's not correct, but it's consistently off by 1: (4 pts)
-It's not correct, but it's consistently off by some other constant: (3 pts)