logo CodeStepByStep logo

section_attendance

Language/Type: C arrays tallying
Related Links:
Author: Allison Obourn (on 2020/09/14)

Write a program that reads data from a file called sections.txt and outputs student section attendance scores.

The file is in the following format:

yynyyynayayynyyyayanyyyaynayyayyanayyyanyayna
ayyanyyyyayanaayyanayyyananayayaynyayayynynya
yyayaynyyayyanynnyyyayyanayaynannnyyayyayayny

Each line represents a section. A line consists of 9 weeks' worth of data.

  • Each week has 5 characters because there are 5 students. Within each week, each character represents one student.
  • a means the student was absent (+0 points)
  • n means they attended but didn't do the problems (+1 points)
  • y means they attended and did the problems (+3 points)
  • Section scores are capped at 20 points.

When reading the input file shown above your program should produce the following output:

Section 1
Student points: 20 16 17 14 11
Student grades: 100.0 80.0 85.0 70.0 55.0

Section 2
Student points: 16 19 14 14 8
Student grades: 80.0 95.0 70.0 70.0 40.0

Section 3
Student points: 16 15 16 18 14
Student grades: 80.0 75.0 80.0 90.0 70.0
Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.