Question
Task 2 Write a method called attendance that reads a file containing student attendance and returns the number of points each student earns for attendance
Task 2
Write a method called attendance that reads a file containing student attendance and returns the number of points each student earns for attendance and their grades for attendance.
Create a file called attendance.txt that contains the following text:
yynyyynnynyynyyynynnyyynynnyynyynnnyyynnynynn nyynnyyyynynnnyyynnnyyynnnnnynynynynynyynynyn yynynynyynyynyynnyyynyynnnynynnynnyynyynynyny
A call to attendance() should produce the following output:
Section 1
Student points: [30, 25, 25, 20, 15]
Student grades: [100.0, 83.3, 83.3, 66.7, 50.0]
Section 2
Student points: [25, 30, 20, 20, 15]
Student grades: [83.3, 100.0, 66.7, 66.7, 50.0]
Section 3
Student points: [25, 25, 25, 30, 20]
Student grades: [83.3, 83.3, 83.3, 100.0, 66.7]
Rules:
Students earn 5 points for reach section attended, up to 30
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
n means the student was absent (+0 points)
y means they attended and did the problems (+5 points)
Your solution should consist of three methods:
countPoints(String line) : returns an array with then containing the attendance record for each student converted into a point total (out of 30)
computeGrades(int[] points) : returns an array containing the grade for each student based on the points they earned in attendance divided by the total points possible (rounded to one decimal point)
results(int section, int[] points, double[] grades) : prints the grades for the students as shown above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started