AP Level A Mid Term Exam (2005)
Name _____________________
class employee
{public employee(String n, int age, double sal, String title){}
private String name;
private int age;
private double salary;
private String title;
1. public String getName(){}
2. public int getAge(){}
3. public double getSalary();
4. public String getTitle(){}
5. public void increaseAge(); // increases by 1 year
6. public void increaseSalary(double percent){}
7. public String toString(){} // returns name
}
_____________________________
class company
{public company();
private employee[] ar = new employee[100];
private int ct = 0;
8. public void printEmployees(){}
9. private int find(String n){} // returns index (location) of employee or -1 if not there
10. public void addEmployee(String n, int a, double sal, String t){} // you may assume there is room for this Employee
11. public void increaseAge(String n){} // increase age by one year for person whose name is sent
12. public void increaseSal(String n, double p){} // increase salary for this person by percentage p – (hint) first you have to find person in array
13. public void fire(String n){} // remove from array if there
}
_______________________________________________________
public class CD {
private String title, artist;
private double cost;
private int tracks;
14. public CD (String name, String musician, double price, int numTracks){}
15. public String toString() {} // return title and artist
______________________________________________________________________
public class Inventory {
private CD [] music;
private int numCDs;
16. public Inventory(int size) // make room in array{}
17. public int size () {}
18. public void addCD (CD record){} // if there isn’t room increase size
19. public void addCD (String name, String art, double p, int n){}
public void increaseCollection () // this function is given
{} // don’t write it
20. public String toString () {} // returns names of all CD's
class student
{private String first;
private String last;
private double avg;
21. public student (String f, String l, double a){}
22. public String getFirst() {}
23. public String getLast() {}
public double getAvg()
{}
24. public String toString()
{} // return full name
}
____________________________________________
public class school
{
private student ar[]; // note array is not sized yet
private final douuble MAX = 100;
int ct = 0;
25. public school()
{ // set up array for 100 students
}
26. public void addStudent(String f, String l, double d)
{ // if there is room add to end otherwise don’t add
}
27. public void printStudents()
{ // print all students
}
28. public void printHonor()
{ // print students with avg >= 90
}
29. public boolean deleteStudent(String f, String l)
{ // delete student - return true if you did otherwise false
}
}