I'm trying to display some project and quiz scores to the console but the console is not displaying anything when I try to run the code. It just shows an empty screen.
Here is the student class:
public class Student { private String firstname; private String lastname; private int studentID; private double[] projects; private double[] quizzes; public Student(String firstname, String lastname, int ID) { firstname = firstname; lastname = lastname; studentID = ID; projects = new double[15]; quizzes = new double[10]; int i = this.projects.length - 1; while (i >= 0){ this.projects[i] = -1; i--; } int i1 = this.quizzes.length - 1; while (i1 >= 0){ this.quizzes[i1] = -1; i1--; } } public boolean setProjectScore(double projectScore, int projectID){ if ((projectID >= projects.length) || (projectID < 0)) { return false; } else { projects[projectID] = projectScore; return true; } } public boolean setQuizScore(double quizScore, int quizID){ if ((quizID >= quizzes.length) || (quizID < 0)) { return false; } else { quizzes[quizID] = quizScore; return true; } } public int getProjectsLength(){ return this.projects.length; } public int getQuizzesLength() { return this.quizzes.length; } public double getProjectScore(int index){ if (index < 0 || index > projects.length -1) { return -1; } return projects[index]; } public double getQuizscore(int index) { if (index < 0 || index > quizzes.length -1) { return -1; } return quizzes[index]; } public String getProjectScoreForID(int ID){ String grade = ""; if(ID<=this.projects.length-1){ if (projects[ID] >= 90) { grade = "A"; } else if (80 <= projects[ID] && projects[ID] < 90) { grade = "B"; } else if (70 <= projects[ID] && projects[ID] < 80) { grade = "C"; } else if (60 <= projects[ID] && projects[ID] < 70) { grade = "D"; } else if (50 <= projects[ID] && projects[ID] < 60) { grade = "F"; } } return grade; } public String getQuizScoreForID(int ID){ String grade = ""; if(ID<=this.quizzes.length-1){ if (quizzes[ID] >= 90) { grade = "A"; } else if (80 <= quizzes[ID] && quizzes[ID] < 90) { grade = "B"; } else if (70 <= quizzes[ID] && quizzes[ID] < 80) { grade = "C"; } else if (60 <= quizzes[ID] && quizzes[ID] < 70) { grade = "D"; } else if (50 <= quizzes[ID] && quizzes[ID] < 60) { grade = "F"; } } return grade; } public int getNextQuizIndex(){ int i = 0; do { if (quizzes[i] == -1.0){ return i; } i++; } while (i < quizzes.length); return -1; } public int getNextProjectIndex(){ int i = 0; do { if (projects[i] == -1.0){ return i; } i++; } while (i < projects.length); return -1; } }
public class Main { public static void main(String[] args) { Student jimmy = new Student(null, null, 0); int currentIndex=0; int projectLength = jimmy.getProjectsLength(); int quizLength = jimmy.getQuizzesLength(); while (currentIndex <= projectLength){ System.out.println(jimmy.getProjectScoreForID(currentIndex)); currentIndex++; } while (currentIndex <= quizLength) { System.out.println(jimmy.getQuizScoreForID(currentIndex)); currentIndex++; } } }