View Full Version : Changing arrays.

04-05-2007, 05:18 PM
Ok one last problem... i hope.
When i run through my Undergrad loop and add the grades it works. but when i add two or more Undergrad students it uses the most recent scores added for all the Undergrad students. I realize i need to do some sort of loop so that i can add more arrays. I can have a maximum of 20 students. in my array. How would i make an array that has a different name every time 1 is added. here is my code.

class Undergrad extends College
int[] tempAct, tempExercise, tempProject;

int ap, ex1, ex2, fEx;

public UnderGrad(String name, int age, String schoolName, int id, double gpa, int apCreds, String major, String minor, boolean time, int examOne, int examTwo, int[] activity, int[] exercise, int[] projects, int finalExam)
super(name, age, id, schoolName, gpa, major, minor, time);
tempAct = activity;
tempExercise = exercise;
tempProject = projects;
ap = apCreds;
ex1 = examOne;
ex2 = examTwo;
fEx = finalExam;

public String toString()
String A, E, P;
A = "";
for(int i = 0; i < 14; i++)
A += tempAct[i] + " ";
E = "";
for(int j = 0; j < 14; j++)
E += tempExercise[j] + " ";
P = "";
for (int k = 0; k < 14; k++)
P += tempProject[k] + " ";

String temp = super.toString();
return temp +"\nExam One Grade: "+ex1+ "\nExam Two Grade: "+ex2+"\nActivity Grades: "+A+"\nExercise Grades: "+E+"\nProject Grades: "+P;


04-08-2007, 09:46 PM
Got it fixed. It was because my arrays in the driver file were declared static. Not sure why it effected it but that is the reason.