Question: class Student { private int SID; private int scores[] = new int[NUMBER_OF_CSC20_LABS]; // write public getter and setter methods for // SID and scores //

 class Student { private int SID; private int scores[] = new

int[NUMBER_OF_CSC20_LABS]; // write public getter and setter methods for // SID and

class Student { private int SID; private int scores[] = new int[NUMBER_OF_CSC20_LABS]; // write public getter and setter methods for // SID and scores // add methods to print values of instance variables. } class Statistics { private int [] lowscores = new int [NUMBER_OF_CSC20_LABS]; private int [] highscores = new int [NUMBER_OF_CSC20_LABS]; private float [] avgscores = new float [NUMBER_OF_CSC20_LABS]; void calculateLow(Student [] a) { // This method will find lowest score and store it in an array names lowscores } void calculateHigh(Student [] a) { // This method will find highest score and store it in an array names highscores } void calculateAvg(Student [] a) { // This method will find avg score for each lab and store it in an array named avgscores } // add methods to print values of instance variables. } class Util { public static Student[] readFile(String fileName) throws IOException { // Reads the file and builds student array. // Open the file using FileReader Object. // In a loop read a line using readLine method. // Tokenize each line using StringTokenizer Object // Each token is converted from String to Integer using parseInt method // Value is then saved in the right property of Student Object. } } Putting it all together: public static void main(String [] args) { Student[] studArr = Util.readFile("studentData.txt"); Statistics stat = new Statistics(); stat.calculateLow(studArr); // add calls for the high and average values // Print the data and statistics, etc. }

Additional materials: Working with Text files: // ReadSource.java shows how to work with readLine and FileReader public class ReadSource { public static void main(String[] arguments) { try { FileReader file = new FileReader("ReadSource.java"); BufferedReader buff = new BufferedReader(file); String line; line = buff.readLine(); while (line != null) { System.out.println(line); line = buff.readLine(); } buff.close(); } catch (IOException e) { System.out.println("Error " + e.toString()); } } }

How do you tokenize a String? The following example illustrates how the String.split method can be used to break up a string into its basic tokens: String[] result = "this is a test".split("\\s"); for (int x=0; x Overview: The final CSC 20 project is to keep records and perform analysis for a CSC 20 class of students Our Spring 2018 CSC 20 lab may have up to 17 students. However, please make a note that this number can be changed since there are more students to be added to the course. There are five labs (assumed we have five) during the section. Each student is identified by a four-digit CSUS student ID number The program is to output the student scores and calculate and print the statistics for each lab. The output is in the same order as the input; no sorting is needed. The input is to be read from a text file. The output from the program should be similar to the following Here is some sample data (for illustration only) Stud L1 L2 L3 L4 L5 1234 78 83 87 91 86 2134 67 77 84 82 79 1852 77 89 93 87 71 High Score 78 89 93 91 86 Low Score 67 77 84 82 71 Average 73.4 83.0 88.2 86.6 78.6 Use one and two-dimensional arrays only. Test your program with the following data - Program should print all the lowest or highest scores for each lab Here is copy of actual data to be used for input. Stud L1 L2 L3 L4 L5 1234 032 017 020 028 034 2134 030 036 030 017 030 3124 030 035 020 030 030 4532 031 017 031 032 027 5678 040 012 035 028 034 6134 034 040 035 018 025 7874 030 030 036 038 018

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!