import java.util.ArrayList;
public class CSStudent
{
String[] requiredGeneralClasses = {"biology", "calculus", "chemistry", "english", "physics", "psychology", "economics"};
String[] requiredInMajorClasses = {"algorithms", "data structures", "numerical analysis", "graphics, databases"};
String[] completedClasses;
int[] gradeForCompletedClasses;
public CSStudent()
{
completedClasses = new String[10000];
gradeForCompletedClasses = new int[10000];
}
public void completeClass(String classs /*class*/, int gradeOnHundredPointScale)
{
int count = 0;
//while(true)
//{
for(int i = 0; ; i++)
{
count++;
if(classs.equals(requiredGeneralClasses[count++]) || classs.equals(requiredInMajorClasses[count++]))
{
completedClasses[count] = classs;
}
else
{
completedClasses[count] = classs;
}
if(gradeOnHundredPointScale <= 100)
{
gradeForCompletedClasses[count] = gradeOnHundredPointScale;
}
}
}
public class CSStudentTester
{
public static void main(String[] args)
{
CSStudent student = new CSStudent();
student.completeClass("biology", 85);
//System.out.println(student.getInMajorGPA());
}
}
ok so I have the above code and I keep getting error for the completeclass method:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at CSStudent.completeClass(CSStudent.java:22) //if(classs.equals(requiredGeneralClasses[count]) || classs.equals(requiredInMajorClasses[count]))
at CSStudentTester.main(CSStudentTester.java:7) //student.completeClass("biology", 85);
can anyone please tell me what am I doing wrong? also I am confused on how should I write the major gpa method. if possible could anyone please write some steps that explain how that method can be done.