Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago