I'm very new to this and I need to write a class, CourseManager, that will use the object Student to store last and first names of students, as well as three exam grades and an ind. average.
public int getID() { return _idNum; } public String getLastName() { return _lastName; } public String getFirstName() { return _firstName; } public double getExamOne() { return _exam1; } public double getExamTwo() { return _exam2;} public double getExamThree() {return _exam3;}
} // end Student
I have some really garbled code for Coursemanager and am having trouble figuring out what to do to make this work.
My code thus far is:
import java.io.*; // Import all classes in java.io package. Save typing. public class CourseManager {
public static void main (String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int initialNumStudents = 0; int maxStudents = 100; int k = 0;//array index for arrays receiving user input int i = 0;//array index for computing exam averages int averageAll = 0;//allows to get data for all students for total average
Student[] = new Student(maxStudents);
for(k= 0; k < maxStudents; k++) {
System.out.print("What is the student's last name?");//allows user to enter last name String line = in.readLine(); if ( line.equals( ".")) break;//allows user to exit loop _lastName[k] = line;
System.out.print("What is the student's first name?");//allows user to enter first name firstName[k] = in.readLine();
System.out.print("What is the student's first exam grade?");//allows user to enter 1st exam exam1[k] = Double.parseDouble(in.readLine());
System.out.print("What is the student's second exam grade? ");//allows user to enter 2nd exam exam2[k] = Double.parseDouble(in.readLine());
System.out.print("What is the student's third exam grade? ");//allows user to enter 3rd exam exam3[k] = Double.parseDouble(in.readLine());
examAvg[k] = Math.round ((exam1[k] + exam2[k] + exam3[k])/3);//formula to average each students //individual average
}
//The following block of code calculates the average exam score for ALL student data. initialNumStudents = k;
for (i = 0; i <= (initialNumStudents - 1);i++) {
averageAll = averageAll + examAvg; }
averageAll = Math.round (averageAll / initialNumStudents);//method to average all scores
//This block of code prints the results into a readable table