Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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());

}

}

}

Page ot 5 ective: This final project is to put together all the key concepts which we learned so far in the class. In this project, you have a flexibility to choose your own design and implementation. You will be asked to describe your work to your instructor when you demonstrate your work upon its completion. The code snippets below are optional. You might consider using them or choose your own design. 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 Page ot 5 ective: This final project is to put together all the key concepts which we learned so far in the class. In this project, you have a flexibility to choose your own design and implementation. You will be asked to describe your work to your instructor when you demonstrate your work upon its completion. The code snippets below are optional. You might consider using them or choose your own design. 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions