Object Oriented Programming in C++ - Lab 4

 

In this lab you will write a program to calculate some statistics about a long jump competition.

There are a number of events in track and field in which athletes compete to see who can achieve the greatest distance: for example, who can jump the farthest, who can jump the highest, who can throw a javelin (a spear) or shot (a cannonball) the farthest. Athletes strive to win the competition by achieving the greatest distance, and also try to achieve a "personal best". A personal best is achieved whenever an athlete achieves a distance that is greater than they have ever managed before.

In this program we will have an array of Athlete objects. Each Athlete object will contain the information about a single athlete: their name, their college, their personal best, and the distance they have achieved in the current competition. Your program will read the data for each athlete into the array, then find and print the winning athlete, print any athletes that have achieved a personal best, and then print out all the athletes.

Class Athlete should have the following data members:

Class Athlete should have the following member functions:

You will have to add one member function and modify one member function in the Distance class:

Assumptions:

  1. To keep things from getting too complicated, you can assume there is no tie - only one athlete has the longest distance.
  2. You will use the ISO C++ string class in this lab. To use the string class, include the <string> header file.
  3. Make your array of Athlete objects big enough to hold 20 athletes.
  4. Read input from the keyboard and print output on the screen. Your program must take input for each Athlete in the following form (each of the following should be on a separate line):
             name
             college
             distance in current competition (enter feet then inches)
             personal best distance (enter feet then inches)
    	
  5. After reading each Athlete, prompt the user to find out whether he/she wants to enter another Athlete. If the user enters ‘y’ or ‘Y’, read another Athlete, otherwise stop reading.
  6. If you want an extra challenge, print out the second and third place winners also.

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002