יום ראשון, 17 באוקטובר 2010

Chapter 4 Test

1. I only found the mistake in the admin class where there was the "index++" missing at the end of the while loop. Without this it cannot move into the next student.

 while (index<seniors.classSize())
    {
        System.out.print(seniors.getStudent(index).getName());
        System.out.println(""+ " " + seniors.getStudent(index).getGPA());
        index++;
     }

2.  After I added the courses I wasn't sure how to find the right method to manipulate a students grade because when I did it did not affect the GPA.

3. It should be Public so that Admin has access to it.

Public double setGPA()
{
     int classes = 0;
     int marks = 0;
     for (int i = 0; i < courseList.size(); i++)
    {
          classes++;
          marks = marks + courseList.get(i).getGrade();
          return marks/classes;
    }

4.
public String toString()
{
String username = "";
for (Lessons item; CourseList)
{
username = username+ "," + item.getCourseTitle();
}

5.
public void doDeansList()
{
     for(Student person : listOfStudents)
     {
        if (person.getGPA()>=88)
        deansList.add(person);
     }

6.
public void printDeansList()
{
    for(Student person : listOfStudents)
    {
      System.out.print(person.getName() + " has a GPA of " + person.getGPA());
     }

7.
public Student findTopStudent()
{
   String topStudent = "";
   Student topStudent = listOfStudents.get(0);
   for (int i = 0; i < listOfStudentz.size(); i++)
   {
    if (listOfStudents.get(i).getGPA() > topStudent.getGPA())
    topStudent = listOfStudents.get(i);
    }
    System.out.println("Top Student is "+topStudent.getName()+" with a GPA of "+topStudent.getGPA());
    }

אין תגובות:

הוסף רשומת תגובה