CS 1401 Assignment #4
Date Assigned: Monday, February 13, 2006 or Tuesday, February
14, 2006.
Due Date: correspondingly, Monday, February 20, 2006, or
Tuesday, February 21, 2006, before the beginning of your lab
section.
Goals: to learn to design objects and value-returning
methods.
Points: This assignment is worth a total of 20 points. No
late assignments will be accepted, but credit will be given for
partially completed assignments turned in on time.
Assignment: In this assignment, we will deal with the same
competition assignment as in Assignment 3, with the following
difference:
- in Assignment 3, we asked you to design one application; the
emphasis was on making things work;
- in this assignment, instead of placing everything into
a single method main, we ask you to make your code more in line
with the object-oriented paradigm; the emphasis now is on designing
objects and methods.
Reminder: To encourage the departments to work better, the
university is thinking of organizing a competition between different
departments, so that students from a winning department will get a
special celebration party.
There are many possible criteria for selecting a winning department:
the number of students n, their average GPA g,
the percentage h of students who are
members of honor societies, the percentage a of students who
are active in
professional organizations (like ACM), and the number p of research
publications co-authored by senior and graduate students, etc. To
select a winning department, we combine these criteria, with
certain weights, into a single rating
r = wn * n + wg * g + wh * h + wa * a + wp * p.
Assume that wn = 1, wg = 50, wh = 1, wa = 2, and wp = 40.
Keep all the weights as named constants, to make it easier to
change them later on.
To help the university, we
must design a template that would compute such a rating for
different departments.
Desired structure: define three classes:
- class Student
whose objects are students;
- class Department whose objects are departments, and
- an application class.
Class Student should contain:
- a field for the student's name,
- a field for the department's name,
- a constructor method for defining a new student object based on two
strings containing, correspondingly, the student's name and the
department's name;
- a method getName that returns the student's name;
- a method setName that changes the student's name;
- a method getDept that returns the department's name;
- a method setDept that changes the department's name.
Class Design should contain:
- a field for the department's name;
- a field for the number of students n
in the department;
- a field for the average GPA g;
- a field for the number H of students who are members of honor
societies;
- a field for the number A of students who are
active in professional organizations;
- a field for the number p of research publications
co-authored by students;
- a constructor method for defining a new department object based on the
required information;
- get and set methods which return and change the
value of each field;
- a method percentHonor that returns the percentage of
students who are members of honor societies;
- a method percentAtive that returns the percentage of
students who are active in professional organizations;
- a method ranking that returns the department's ranking.
Named constants related to weights should be defined in the class
Department.
The application class should do the following:
- ask the user (the student who types in this information) for
the following information:
- his or her name;
- the name of the student's department;
- the number of students n in this department;
- the average GPA g of students in the department;
- the number H of students who are members of honor societies;
- the number A of students who are active in
professional organizations (like ACM); and
- the number p of research publications co-authored by students.
- based on the answers, construct the corresponding objects of type
Student and of type Department;
- use the methods defined for such objects to
print a report that displays:
- the name of the department;
- the name of the reporting person;
- the number of students in the department;
- the average GPA of students in this department;
- the number and percentage of students who are members of honor
societies;
- the number and percentage of students who are active in
professional organizations;
- the number of research publications co-authored by students; and
- the resulting rating of the department.
Deliverables: as announced in the labs.
Homework part. On a separate sheet of paper, please do
Exercise 9 (p. 145), and Ex. 5
Ex. 3 (p. 147).
Explain your answers. Return the sheet with your answers to your TA by,
correspondingly, Monday February 20 or Thursday February 21
before the beginning of your lab session.