I'm working on an a grading program that will require the use of a couple classes. The program contains a list of "program assignments" which there are 5, and 3 test scores. The Driver class contains the scores for the students. I'm stuck writing the average methods :$ Along with the total exam scores/program scores (populateExamAverages/populateProgramAverages). Any help will be appreciated! Here's the classes I'm using... Thanks in advance!!
public class ITCourseGrade {
private final static int MAXCAPACITY = 30;
private Student[] studentArray = new Student[MAXCAPACITY];
private double[] examAverages;
private double[] programAverages;
private int numberOfStudents;
public ITCourseGrade(Student[] studentArray) {
for (int i = 0; i < studentArray.length; i++) {
this.studentArray[i] = studentArray[i];
}
examAverages = new double[3];
programAverages = new double[5];
numberOfStudents = studentArray.length;
}
private int[] programTotals() {
int[] programTotals = {20, 20, 20, 20, 20};
return programTotals;
/*
private method that returns an array containing the total points for
every program. Used by populateProgramAverages
*/
}
public void populateProgramAverages(int[] programScores) {
int total = 0;
double[] programScores = {0.0, 0.0, 0.0, 0.0, 0.0,};
for (int i = 0; i < numberofStudents.length; i++) {
System.out.println("Student" + studentArray.length);
for( int j = 0; j < programTotals.length ; j++){
total += programScores[j];
return ( double ) total / programScores.length;
/*
method that populates the programAverages array with the
averages for each exam. Needs to call programTotals()
*/
}
public void printProgramAverages() {
for (int i = 0; i < programAverages.length; i++) {
System.out.println("The average score for program " + (i +1) + " is: "
+programAverages[i]);
}
}
private int[] examTotals() {
int[] examTotals = {100, 100, 100};
return examTotals;
/*
private method that returns an array containing the total points for
every exam. Used by populateExamAverages
*/
}
public void populateExamAverages() {
for (int i = 0; i < studentArray.length; i++) {
for( int j = 0; j < ExamScore.length ; j++){
/*
method that populates the examAverages array with the
averages for each exam. Needs to call examTotals()
*/
}
public void printExamAverages() {
for (int i = 0; i < examAverages.length; i++) {
System.out.println("The average score for exam" + (i + 1) + " is: " +
examAverages[i]);
}
}
}
The Student class:
public class Student {
private String firstName;
private String lastName;
private String techId;
private int[] examScores;
private int[] programScores;
public Student(String firstName, String lastName, String techId, int[] examScores, int[] programScores) {
this.firstName = firstName;
this.lastName = lastName;
this.techId = techId;
this.examScores = examScores;
this.programScores = programScores;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getTechId() {
return techId;
}
public void setTechId(String techId) {
this.techId = techId;
}
public void setExamScores(int[] examScores) {
this.examScores = examScores;
}
public int[] getExamScores() {
return examScores;
}
public void setProgramScores(int[] programScores) {
this.programScores = programScores;
}
public int[] getProgramScores() {
return programScores;
}
public int totalExamScores() {
/*
returns the total exam scores for this student
iterate through and add
*/
}
public int totalProgramScores() {
/*
returns the total program scores for this student
*/
}
public int totalPoints() {
return totalExamScores() + totalProgramScores();
}
public char letterGrade() {
/*
returns an 'A' if the total points earned by the student is >= 360
returns a 'B' if the total points earned by the student is >= 320
returns a 'C' if the total points earned by the student is >= 280
returns a 'D' if the total points earned by the student is >= 240
returns a 'F' if the total points earned by the student is < 240
*/
}
}
And finally the Driver class
public class Driver {
public static void main(String[] args) {
int[] stud1ExamScores = {56, 76, 86};
int[] stud1ProgramScores = {10, 15, 16, 18, 10};
Student student1 = new Student("The", "Devil", "666", stud1ExamScores, stud1ProgramScores);
int[] stud2ExamScores = {100, 90, 100};
int[] stud2ProgramScores = {17, 19, 20, 18, 20};
Student student2 = new Student("Joe", "Blow", "123", stud2ExamScores, stud2ProgramScores);
Student[] studentArray= {student1, student2};
ITCourseGrade course = new ITCourseGrade(studentArray);
System.out.println();
course.populateExamAverages();
course.printExamAverages();
System.out.println();
course.populateProgramAverages();
course.printProgramAverages();
}
}