0

I'm working on 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. I'm stuck writing the average methods Along with the total exam scores/program scores. Any help will be appreciated! Here's the classes I'm using... Thanks in advance!!


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 UndergraduateStudent("The", "Devil", "666", "Undergraduate", stud1ExamScores, stud1ProgramScores);
		
		int[] stud2ExamScores = {100, 90, 100};
		int[] stud2ProgramScores = {17, 19, 20, 18, 20};
		Student student2 = new GraduateStudent("Joe", "Blow", "123", "Graduate", stud2ExamScores, stud2ProgramScores, 89);
		
		Student[] studentArray= {student1, student2};
		Course course = new Course214Section1(studentArray);

		System.out.println();
		course.populateExamAverages();
		course.printExamAverages();
		System.out.println();
		course.populateProgramAverages();
		course.printProgramAverages();
	
		int[] stud3ExamScores = {70, 80, 90};
		int[] stud3ProgramScores = {10, 20, 20, 20, 30};
		Student student3 = new UndergraduateStudent("Joe", "College", "321", "Freshman", stud3ExamScores, stud3ProgramScores);
		
		int[] stud4ExamScores = {80, 80, 80};
		int[] stud4ProgramScores = {10, 10, 10, 10, 10};
		int termPaper = 80;
		Student student4 = new GraduateStudent("Bob", "Barker", "456", "Graduate", stud4ExamScores, stud4ProgramScores, termPaper);
		
		Student[] myArray = {student3, student4};
		course = new Course483Section1(myArray);
		
		System.out.println();
		course.populateExamAverages();
		course.printExamAverages();
		System.out.println();
		course.populateProgramAverages();
		course.printProgramAverages();
		System.out.println();
		Student[] studArray = course.getStudentArray();
		for (int i = 0; i < studArray.length; i++) {
			System.out.print(studArray[i] + " ");
			System.out.println(studArray[i].totalPoints() + " " + studArray[i].letterGrade());
		}
	}
}

Student Class:

public abstract class Student {
	private String firstName;
	private String lastName;
	private String techId;
	private String classStanding;
	private int[] examScores;
	private int[] programScores;
	
	public Student(String firstName, String lastName, String techId, String classStanding, int[] examScores, int[] programScores) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.techId = techId;
		this.classStanding = classStanding;
		this.examScores = examScores;
		this.programScores = programScores;
	}
	
	public int totalExamPoints() {
		//returns the total number of exam points
	}
	
	public int totalProgramPoints() {
		//returns the total number of program points
	}
	
	public abstract int totalPoints();
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public void setTechId(String techId) {
		this.techId = techId;
	}
	
	public void setClassStanding(String classStanding) {
		this.classStanding = classStanding;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public String getTechId() {
		return techId;
	}
	
	public String getClassStanding() {
		return classStanding;
	}
	
	public void setExamScores(int[] examScores) {
		this.examScores = examScores;
	}
	
	public void setProgramScores(int[] programScores) {	
		this.programScores = programScores;
	}
	
	public int[] getProgramScores() {
		return programScores;
	}
	
	public int[] getExamScores() {
		return examScores;
	}
	
	public abstract char letterGrade();
}

Course Super Class:

public abstract class Course {
	private Student[] studentArray;
	private double[] examAverages;
	private double[] programAverages;
	private int numberOfStudents;
	
	public Course(Student[] studentArray) {
		this.studentArray = new Student[studentArray.length];
		for (int i = 0; i < studentArray.length; i++) {
			this.studentArray[i] = studentArray[i];
			examAverages = new double[3];
			programAverages = new double[5];
			numberOfStudents = studentArray.length;
		}
	}
	
	public Student[] getStudentArray() {
		return studentArray;
	}
	
	public double[] getExamAverages() {
		return examAverages;
	}

	public double[] getProgramAverages() {
		return programAverages;
	}
	
	public int getNumberOfStudents() {
		return numberOfStudents;
	}
	public abstract int[] programTotals();
	public abstract int[] examTotals();
	public abstract void populateExamAverages();
	public abstract void populateProgramAverages();
	public abstract void printExamAverages();
	public abstract void printProgramAverages();
}

Course214Section1 class:

public class Course214Section1 extends Course {
	
	public Course214Section1(Student[] studentArray) {
		super(studentArray);
	}
	
	public int[] programTotals() {
		//returns an array containing the total scores for the programs;
	}
	
	public void populateProgramAverages() {
		//populates the programAverages array inherited from Course
	}
	
	public void printProgramAverages() {
		for (int i = 0; i < getProgramAverages().length; i++) {
			System.out.println("The average score for program " + (i +1) + " is: " + getProgramAverages()[i]);
		}
	}
	
	public int[] examTotals() {
		//returns an array containing the total scores for the exams
	}
	
	public void populateExamAverages() {
		//populates the examAverages array inherited from Course
	}
	
	public void printExamAverages() {
		for (int i = 0; i < getExamAverages().length; i++) {
			System.out.println("The average score for exam" + (i + 1) + " is: " + getExamAverages()[i]);
		}
	}
}

Course483Section1 class:

public class Course483Section1 extends Course {
	
	public Course483Section1(Student[] studentArray) {
		super(studentArray);
	}	
	
	public int[] programTotals() {
		//returns an array containing the total scores for the programs;
	}
	
	public void populateProgramAverages() {
		//populates the programAverages array inherited from Course
	}
	
	public void printProgramAverages() {
		for (int i = 0; i < getProgramAverages().length; i++) {
			System.out.println("The average score for program " + (i +1) + " is: " + getProgramAverages()[i]);
		}
	}
	
	public int[] examTotals() {
		//returns an array containing the total scores for the exams
	}
	
	public void populateExamAverages() {
		//populates the examAverages array inherited from Course
	}
	
	public void printExamAverages() {
		for (int i = 0; i < getExamAverages().length; i++) {
			System.out.println("The average score for exam" + (i + 1) + " is: " + getExamAverages()[i]);
		}
	}
}

Graduate Letter:

public class GraduateStudent extends Student {
	
	private int termPaper;
	
	public GraduateStudent(String firstName, String lastName, String techId, String classStanding, int[] examScores, int[] programScores, int termPaper) {
		super(firstName, lastName, techId, classStanding, examScores, programScores);
		this.termPaper = termPaper;
	}
	
	public int totalPoints() {
		//returns total number of points this graduate student has earned
	}
	
	public char letterGrade() {
		// returns a letter grade based on total points.
		// 90% of the total points gets an 'A'
		//80% of the total points gets a 'B'
		//etc.
	}
	
	public String toString() {
		String returnValue = getFirstName() + " ";
		returnValue += getLastName() + " ";
		returnValue += getTechId() + " ";
		returnValue += getClassStanding();
		return returnValue;
	}
}

Undergraduate Letter:

public class UndergraduateStudent extends Student {
	
	public UndergraduateStudent(String firstName, String lastName, String techId, String classStanding, int[] examScores, int[] programScores) {
		super(firstName, lastName, techId, classStanding, examScores, programScores);
	}
	
	public int totalPoints() {
		//returns the total number of points this undergraduate student has earned
	}
	
	public char letterGrade() {
		// returns a letter grade based on total points.
		// 90% of the total points gets an 'A'
		//80% of the total points gets a 'B'
		//etc.
	}
	public String toString() {
		String returnValue = getFirstName() + " ";
		returnValue += getLastName() + " ";
		returnValue += getTechId() + " ";
		returnValue += getClassStanding();
		return returnValue;
	}
	
}

Driver when run should have the following output:

The average score for exam1 is: 75.0
The average score for exam2 is: 80.0
The average score for exam3 is: 85.0

The average score for program 1 is: 10.0
The average score for program 2 is: 15.0
The average score for program 3 is: 15.0
The average score for program 4 is: 15.0
The average score for program 5 is: 20.0

Joe College 321 Freshman 340 B
Bob Barker 456 Graduate 370 C

Edited by javaSux: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by stultuske
0

and what is the problem you're having?
since you're nowhere actually calculating the average (not as far as I've seen) I don't doubt you don't get the output you 're hoping for

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.