My program is not printing out details from my ArrayList that is drawn from a text file. Text file details are spilt into 2 in a database manner sharing one similarity.
I know I am leaving out all my other classes but I would like to know what it is printing or where is it calling from?
Program output from my text file/ ArrayList:
Students above average: CourseworkStudent@53f65459 CourseworkStudent@3b088d51
Student below average: CourseworkStudent@1786dec2 CourseworkStudent@74650e52 CourseworkStudent@15d0c81b
Main Client
public class MainClient {
public static int choice;
public static Scanner kb = new Scanner(System.in);
ArrayList<Student> courses = new ArrayList<Student>();
ArrayList<Student> students = new ArrayList<Student>();
public void studentTxtRead() {//Reading of Student.txt
Scanner studFile = null;
try {
studFile = new Scanner(new File("Student.txt"));
while(studFile.hasNextLine()){
String line = studFile.nextLine();
String[] data = line.split("\\s+");
students.add(new Student(data[0], data[1], data[2], Long.parseLong(data[3])
,Integer.parseInt(data[4]),Integer.parseInt(data[5]), Integer.parseInt(data[6])));
}//end of while loop
}//end of try loop
catch(FileNotFoundException ex){
System.out.println("FILE NOT FOUND");
}
studFile.close();
}//end of studentTxtRead
public void courseworkStudentAvg(){
double total = 0.0;
int count = 0;
for(int i = 0; i < courses.size(); i++){
if(courses.get(i) instanceof CourseworkStudent) {
CourseworkStudent courseW = (CourseworkStudent)courses.get(i);
total += courseW.getCourseMarks();
count++;
}//end of if
}//end of for
double avg = total/count;
System.out.println("Students above averge: ");
for(int i=0; i<courses.size(); i++) {
if(courses.get(i)instanceof CourseworkStudent) {
CourseworkStudent courseW =(CourseworkStudent) courses.get(i);
if(courseW.getCourseMarks()> avg) {
System.out.println(courseW);
}//end of if
}//end of if
}//end of for
System.out.println("\nStudent below average: ");
for(int i =0; i<courses.size(); i++) {
if(courses.get(i) instanceof CourseworkStudent) {
CourseworkStudent courseW = (CourseworkStudent) courses.get(i);
if(courseW.getCourseMarks()< avg) {
System.out.println(courseW);
}//end of if
}//end of if
}//end of for
}//end of courseworkStudentAvg
public void calculateCouGradeMarks(){//calculate grade/marks for coursework
for(int i = 0; i < courses.size(); i++){// Calculate grades for Course Student
if(courses.get(i) instanceof CourseworkStudent){
CourseworkStudent courW = (CourseworkStudent) courses.get(i);
courW.CGrading();
}
}
}//end of CalculateCouGradeMarks