Back to Set 3

Code Challenge: Grade Book

Difficulty  

divider

The Brief

What they asked for
Here are the marks for a class. I want the total, the average,
the highest, and how many are above the pass mark. And I do
not want to retype anything when a student joins.

Write your requirements list before you write any code. This set also asks you to name the table and the function before you start — what is in the table, and what your function takes and does.


Notes

  • Terminal or window, your choice. Say which in your requirements list.
  • Four answers, one table, and every one of them is a traversal. Write the first one carefully and the rest are the same shape.
  • The highest is the interesting one. You cannot compare against nothing, so what does the running best start at, and why?
  • total / #scores is the average, and Lua's / does not truncate. Decide what you want displayed.
  • Not retyping anything is the actual requirement. Adding a mark should mean adding a number and nothing else.

What Success Looks Like

  • Adding a score to the table changes every answer, with no other edit
  • All four answers are correct for a table you worked out by hand
  • The accumulators are above the loops, not inside them
  • An empty table does not produce nonsense — or you have said what it does

Check it against a table of three numbers you can do in your head. Then add a fourth and check again.


Submit

Your requirements list and your program folder, named cc-grade-book.

Commence Challenge