Im trying to write a program which has a method Exam mark This contains objects of pupil class and a string that gives the pupils name. The method should return the pupils exam mark and their name. if there is a pupil called joe and their exam score is 32 then when joe is passes 32 should be printed.
In the student class i have getters, for getexamscore and in a subclass i have the getter getpupilname. the vector elements should be in the pupil class.
If the pupil is not in the class -1 should be returned.
Here is my method and everything must be in only this method:
import java.util.*;
public class vectors
{
public int lookforMark(Vector <pupil> v, String name)
{
int examscoremark=0;
name="";
try{
for(int i=0; i<=v.size(); i++){
try
{
int element= v.elementAt(i).getexamscore();
String element2= v.elementAt(i).getpupilname();
}
catch(Exception e)
{
System.out.println("there is an error");
return -1;
}
}
}
Can someone help me on returning the exammark with the pupil name?