ITEC 320: Program 2


Due Date: 11:59:59 p.m. Thursday 2/20/2020

Submit command: submit itec320-01 pairings.adb


Last modified:
Updates:

  1. 2020 Feb 16 05:03:44 PM: Set due date
  2. 2020 Feb 10 04:03:33 PM: Assignment checker up and running. Removed DRAFT.

You should now use this URL for the assignment checker: itec-noki01. The old one will disappear.
You can see an example of this program at assignment checker (which uses gnoga to integrate the GUI, web server, and problem solution). On-campus or VPN session required.


Teams A and B are involved in a contest between pairs of players, one from Team A and one from B. Each player has a skill level which is an integer in the range 1 .. 1000, inclusive. The input to your program is the list of pairs of the skill levels of pairs of players, with the value for Team A listed first in each pair. There will be between 2 and 100, inclusive, pairs in the input. End of file marks end of the input. In the first round of the contest, pairs are formed as given in the input. In the remaining rounds the order is as specified below.

Here is an example input file:
  6   21
 15   15
 25   40
 9   28
  6   24
In this example, each team has five players, and since the teams alternate in the input, 6 and 25 are skills of Team A players 21 and 40 are skills of Team B players, and both teams have a 15.

Your program is to calculate the number of wins/ties for A and B as well as the average win size for each team. If there are no wins, the average win size is 0.0. Your program is to calculate this information for the original player pairings (ie as in the input) as well as several different pairings of the original players. Your program should do the following:
  1. Calculate and print the results from the original pairings, as in the input

  2. Reduce the team sizes: Determine which team has the most wins. Remove from this team the player with the highest skill on that team and from the other team the player with the lowest skill. In other words, the team with the most wins will lose their best player and the team with the fewest wins will lose their worst player. If there is a tie for number of wins, then both teams lose their worst player. We will call the teams with a player removed the reduced teams. If two players or more players on a team all have the same low or high skill, then the first player (based on input order) with that skill should be removed.

  3. Calculate and print results from pairings of the players in the reduced teams, in the original order.

  4. Calculate and print results from pairings between the best of reduced team A down to the worst of reduced A against the best of reduced team B down to the worst of reduced B.

  5. Calculate and print results from pairings between the best of reduced team A down to the worst of reduced A against the worst of reduced team B up to the best of reduced B.
For the example input file above, the four sets of pairings would be
                                  6         21
                                 15         15
                                 25         40
                                  9         28
                                  6         24

                                 15         21
                                 25         15
                                  9         28
                                  6         24

                                 25         28
                                 15         24
                                  9         21
                                  6         15

                                 25         15
                                 15         21
                                  9         24
                                  6         28
For the example input file above, the expected output would be:
Original pairings:
    Wins for A:   0
    Wins for B:   4
    Ties:         1
    Average A win:   0.0
    Average B win:  16.8

Reduced team pairings:
    Wins for A:   1
    Wins for B:   3
    Ties:         0
    Average A win:  10.0
    Average B win:  14.3

Reduced best vs best pairings:
    Wins for A:   0
    Wins for B:   4
    Ties:         0
    Average A win:   0.0
    Average B win:   8.3

Reduced best vs worst pairings:
    Wins for A:   1
    Wins for B:   3
    Ties:         0
    Average A win:  10.0
    Average B win:  14.3
Input Format and Error Checking: If any of these errors occur, your program should output a message that explains what error occurred and then end execution.

Additional requirements:

  1. Define and use at least one procedure that has at least one out or an in out mode parameter

  2. Define and use at least one function that has at least one parameter.

  3. Make good use of types (ie either range attribute or new subtypes or new integer types).

  4. Your main routine should consist of only a very few statements (ie 3 or 4). The bulk of the work of the program should be in the procedures, not the main routine.

  5. No global variables! All communication with subroutines should be through parameters.
Output specification:
  1. Your output should follow the format of the example.
  2. Your program is to have no prompts.
  3. There is to be at least one blank immediately following a colon.
  4. Values should be lined up in columns (ie right justified) as shown.
  5. Floating point values should be output with one place to the right of the decimal point.
  6. A blank line should appear between information on pairings.
Other points:
  1. Notice that "Average A win" means the size of the average win for A. Similarly for B.
  2. You may use any sort routine that you wish to sort your arrays.
  3. Any data files that you use can be created with any editor, but make sure that you create your data file on the same OS that you use to compile and run your program. You do not need to submit your data file.
  4. The number of pairs is unknown but between 2 and 100, inclusive, and processing is to continue until end of file is reached or an input error is found. To test for the end of file on standard input, you should use the boolean function Ada.Text_IO.End_Of_File.

Style: Your program should follow my style guide. In particular, please note the use of consistent indentation, named constants, and descriptive constant and variable names. Please remember that the first thing in any program file should be a comment that gives a brief overview of what the file contains (and should do). Also remember to keep your lines less than 80 characters long. Not only does this mean that printouts won't run off the side of the page, but it also makes your programs look neater on an 80 column wide xterm window (a popular size). Please ask if you have questions about style.

Submission: Use the submit command to turn your program in for grading. You may submit as many times as you like, but only the last submission is kept. In particular, be aware that since only the last submission is kept, if the last one is late, then your assignment is late and will thus receive a late penalty. Also remember that you must be on rucs for submit to work. To submit your work for grading do the following:
Grading criteria: When grading I will check at least the following specifications:


Dr. Okie's Home Page,
Last modified on