Java Reference
In-Depth Information
The definition of the
class
Student
has the following form: (You can complete the
definition of this class as an exercise.)
import
java.io.*;
public class
Student
extends
Person
{
private int
sId;
//variable to store the
//student ID
private int
numberOfCourses;
//variable to store the number
//of courses
private boolean
isTuitionPaid;
//variable to indicate if
//the tuition is paid
private
Course [] coursesEnrolled;
//array to store
//the courses
private char
[] courseGrades;
//array to store the
//course grades
//Place the definitions of the instance methods
//as discussed here.
//...
}
Now that we have designed the
class
es
Course
and
Student
, we will use these
classes to complete the program.
Because the
toString
method of the
class
Student
does the necessary computa-
tions to print the final grade report, the main program has very little work to do. In
fact, all the main program must do is create the objects to hold the students' data, load
the data into these objects, and then print the grade reports. Because the input is in a
file and the output will be sent to a file, we create appropriate objects to access the
input and output files. Essentially, the main algorithm for the program is:
1. Declare the variables.
2. Open the input file.
3. Open the output file.
4. Get the number of students registered and the tuition rate.
5. Load the students' data.
6. Print the grade reports.
MAIN
PROGRAM
Variables
This program first reads the number of students from the input file and then creates
the array,
studentList
, to hold the students' data. The size of
studentList
is
equal to the number of students.
Student[] studentList;
int
noOfStudents;
double
tuitionRate;
Search WWH ::
Custom Search