IUP Computer Science
COSC 110      Fall 05

Project #4
(Trip to the Botanical Garden)
(due  2 Nov 05 )

Miss Peach took her fifth grade class to the botanical garden for a field trip.  Each student is assigned the task of writing down the names of 10 flowers that are their favorites (or at least ones that they like or find interesting) at the garden.  To keep these lists reasonable, Miss Peach asked the students to write down only the common family names for their favorites.  (Writing the scientific names would be very prone to error.)  The only drawback of this approach is that some students wrote down the same family name more than once, because they found several different species within the family that they wanted to include each among their favorites.  Each flower family has many different species.

For the most part, the students did as Miss Peach asked.  However, some students did not find 10 favorites; they found fewer.  Also, some students did not write down the whole family name.  They wrote only the first few letters - but at least those letters were enough to distinguish which family they meant.  Miss Peach collected all of the student information and had it put into a file named favorites.txt; now, she needs to extract information that she will use in a report to the school superintendent about the trip.  You are to write a program to extract the information the Miss Peach needs.

favorites.txt   contains information in the following form.

On the first line:

Miss Peach              Family_names_of_Miss_Peach's_Three_Favorite_Flowers

This is the teacher's name and her three favorite flower families.

On each subsequent line:

student_name  trip_rating  no_of_favorites  favorite_family_names

The student's name includes a first name and a last name, separated by a space.  The trip rating is an integer from 1 to 10 which indicates the student's rating for this trip.  The number of favorites is an integer from 0 to 10 which indicates how many favorites the student found.  This is followed by the specified number of favorite flower family names.  There is at least one space between each two elements on the line.  All family names are a single word with no embedded spaces.  Some family names are present only in prefix form; that is, only the beginning letters are present.  Following is an example of one student line from the file:

Broom Hilda  5  6  Mallow  Honeysuckle  Orchid  Lily  Pickerelweed  Primrose

You can get a copy of favorites.txt from the I:\ drive (I:\jlwolfe\110\favorites.txt) from the P:\ drive (P:\courses\fall05\cosc\cosc110\xxx\information\favorites.txt where xxx is your section number) or from WebCT (entry just after Project #4 in the Outline).

Your program must read the favorites.txtfile, calculate and display the following information on the screen with appropriate identification.
 

  1. The number of times that students chose each of Miss Peach's favorite flower families as a favorite of their own.
  2. The average rating that the class gave the trip.
  3. The total number of favorites that the students reported.
  4. The name of the student who rated the trip the lowest and what that lowest rating was.  If there is a tie in this regard, give the name of any of the students with the equally low rating.
  5. The name of the student who listed the fewest flower families and how many families that was.  If there is a tie in this regard, give the name of any of the students with the equally low rating.
  6. The number of students who rated the trip 10 but did not find 10 favorite flowers.
Two of these actions (#4 and #5) require your program to find the smallest of something.  Your program is required to have a function named Smallest which makes the key comparison and updates the "smallest so far"  in identifying the smallest something overall.  Your program is required to invoke (use) this function twice, to do actions #4 and #5.

Hand in a printout of your well documented program made with Visual Studio.  Hand in a printout of the program's output to the screen, captured in the usual way.  Copy your .cpp file (named after yourself) to the handin folder on the P: drive.