// Tyler Rigsby, CSE 142 // Computes several students' section attendance scores from // poorly formatted data using array tallying import java.util.*; import java.io.*; public class SectionAttendance { // constants? public static void main(String[] args) throws FileNotFoundException { // make scanner // loop over each line (section): // get points for each // get percentages for each // report results Scanner input = new Scanner(new File("sections.txt")); while (input.hasNextLine()) { String line = input.nextLine(); int[] studentPoints = getPoints(line); reportResults(studentPoints); } } // Takes a line of input as a parameter, and return an array containing // the number of points each user received. public static int[] getPoints(String line) { int[] counts = new int[5]; for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); int points = 0; if (c == 'y') { points = 3; } else if (c == 'n') { points = 1; } int student = i % 5; counts[student] += points; if (counts[student] > 20) { counts[student] = 20; } } return counts; } // (will) Take the section number, an array with the number of points each user received, and // an array with each person's percentage, and prints these statistics. public static void reportResults(int[] points) { System.out.println("Student Points: " + Arrays.toString(points)); } }