[CS230 Home Page] [Syllabus] [Assignments] [Documentation] [CS Dept.]
There are many online resources that provide valuable information about graduate programs in Computer Science, and how to choose programs that best fit an individual student's interests and needs. One particularly interesting website allows you to customize the ranking of graduate programs based on your own weighting of various criteria used to judge the quality of these programs and was created by Geoff Davis while he was on the faculty at Dartmouth College.
In this problem, you will implement a small version of a program that produces a customized ranking of Computer Science graduate programs.
Sort.java, in particular the sortArray() method,
and its auxiliary swap() method. Study the code carefully. Hand-run the code in a couple of sample
inputs.
Once you are sure you have understood the overall algorithm, add a short paragraph -as comments- to the file
summarizing the strategy in abstract terms. Please do not re-state every code statement in words!
In task 3, you will modify these two methods to fit your specific needs there.
In this file define a class,
School, to store information about a single graduate school program.
A School instance has the following properties:
School class, each of the above properties should be
represented as a private instance variable. You can assume that the value of
each of the ratings above is an integer in the range [1 .. 10].
Add two more instance
variables to your School class:
Your task: (Please add the code in the following order!)
School objects, given values
for the four properties.
School.
School class.
computeRating(), that computes the overall rating of a School
instance and sets the appropriate instance variable (overall rating).
Different users may value each of the ranking factors (academic programs,
research and publications) differently.
The method definition should reflect that. In particular, the method should
take three weights, with values in the integer range [1 .. 5], to be associated with each of the
three evaluation factors. Then, it should compute the overal rating as the weighted sum,
Σ(weight * factor), of the three evaluation factors, and set the overall rating accordingly.
main() method to test your work.
In this file define a new class, GradSchools,
that stores information about a collection of School
objects. Use an array as the container for the School objects. Once the user enters her weights
for Academics, Research and Publications, the program computes the overall rating for all schools in the collection,
as the weighted sum of the three rating factors. Then, it sorts the schools according to each one
of the ranking factors, and prints the results. (See the Sample run provided at the end of this
document.)
Your task: (Please add the code in the following order!)
GradSchools class.
GradSchools class.
GradSchools.
(Hint: This method should implicitely use the
printing method in the School class!)
addSchool(), that adds a School instance to the collection.
computeRatings() that computes the overall rating for all schools in the
collection, based on the three weights that are passed as parameters to it.
rankSchools() to rank-order all the schools in the collection, based on its
input factor. The input to the method should be a String, specifing one of the three ranking factors
(academics, research, publications), or the overall rating, to be used as the criterion for ranking.
For example, suppose that a GradSchools object
has been created named myGradSchools.
The method call
> myGradSchools.rankSchools("Academics")
Ranking of schools from highest to lowest using "Academics" as the factor:
MIT
CMU
Stanford
Univ. of Illinois
UC Berkeley
Univ. of Washington
Cornell
Princeton
> myGradSchools.rankSchools("Overall")
Ranking of schools from highest to lowest using "Overall" as the factor:
Stanford
CMU
MIT
Univ. of Illinois
UC Berkeley
Cornell
Princeton
Univ. of Washington
The rankSchools() method stores each school's rating value for the desired factor into
the school's rank value instance variable.
Then, the sorting process uses the rank value to sort the School objects in the array. At the end, the method
prints the names of the ranked schools. It is advisable that rankSchools() method calls a
sorting helper method to sort the array of schools based on their rank value. Use the sorting method you
worked with in Task 1 as your starting point in writing the method that sorts the
array of School objects. You only need to make few modifications to the method that sorts an array of
integers, in order to make it sort an array of School objects! (Feel free to make changes to the
arguments of the method, or make it an instance method, as opposed to a class one, as it fits your needs.)
main()
method with code to test the methods defined in the
GradSchools
class. Add test cases to thoroughly test your
code, including calls to the method rankSchools().
.java code files.
Also, drop off an electronic copy of your code files by connecting to your personal account (cd to your drop dir)
and executing the following command:
submit cs230 GradSchools *.*
Note: Be sure to include top-of-the-file comments in each of your code files.
Assign2 tm$ java GradSchools Please provide 3 weights (1..5) for Academics, Research and Publications Assign2 tm$ java GradSchools 3 5 4 There are 4 schools in the database: Name: MIT Rating of Academics: 10 Rating of Research: 10 Rating of Publications: 7 Overall rating: 108 Current rank value: 0 Name: Stanford Rating of Academics: 8 Rating of Research: 10 Rating of Publications: 9 Overall rating: 110 Current rank value: 0 Name: CMU Rating of Academics: 7 Rating of Research: 8 Rating of Publications: 6 Overall rating: 85 Current rank value: 0 Name: UC Berkeley Rating of Academics: 9 Rating of Research: 9 Rating of Publications: 9 Overall rating: 108 Current rank value: 0 Ranking of schools from highest to lowest using Acedemics MIT UC Berkeley Stanford CMU Ranking of schools from highest to lowest using Effectiveness of Research Stanford MIT UC Berkeley CMU Ranking of schools from highest to lowest using Pubs UC Berkeley Stanford MIT CMU Ranking of schools from highest to lowest using Overall Stanford MIT UC Berkeley CMU