ITEC 320: Program 2


Due Date: 11:59:59 p.m. Monday, 9/28/2009

Submit Command: submit itec320-01 pairings.adb

Also submit: Structure chart, in class on Monday, 9/28/2009


Update 9/23/09:

  1. Corrected the last average B win in the sample run, changing it from 7.0 to 14.0.

Teams A and B are involved in a contest which is run by forming pairs made up of a player from A and a player from B. The players in a pair play a game and the score of each player is recorded. Valid scores are integers in the range 1 .. 1000. The input to your program is the list of pairs of scores, with the score for Team A listed first in each pair. There may be up to 100 pairs in the input. Here is an example input file:
 10   20
 25   11
 9   17
 15   15
In this example, each team has 4 players 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 several real and simulated player pairings:
  1. The original pairings

  2. simulated pairings between the best of A down to the worst of A against the same range for B

  3. simulated pairings between the best of A down to the worst of A against the opposite range for B (ie best of A vs worst of B down to worst of A vs best of B)
For the example input file above, the simulated pairings would be
 25 20
 15 17
 10 15
 9  11

 25 11
 15 15
 10 17
 9  20
For the example input file above, the expected output would be:
Original pairings:
    Wins for A:  1
    Wins for B:  2
    Ties:        1
    Average A win:  14.0
    Average B win:   9.0

Best vs best pairings:
    Wins for A:  1
    Wins for B:  3
    Ties:        0
    Average A win:   5.0
    Average B win:   3.0

Best vs worst pairings:
    Wins for A:  1
    Wins for B:  2
    Ties:        1
    Average A win:   7.0 14.0
    Average B win:   9.0
Error Checking: For this program, you cannot assume that the input is correct, and you are to detect the following errors: If any of these errors occur, your program should output an explanatory message 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. Define and use a subrange type that you declare

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

  5. No global variables!

  6. You must also submit a neat and legible structure chart of your program showing procedures that are called and information passed.
Output specification:
  1. Your output should follow the format of the example.
  2. Your program is to have no prompts.
  3. There are to be no trailing blanks on the lines.
  4. There is to be at least one blank immediately following a colon.
  5. Values should be lined up as shown.
  6. Floating point values should be output with one decimal place.
  7. A blank line should appear between information on pairings.
Other points:
  1. Your program should be called pairings.adb
  2. 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.
  3. The number of pairs is unknown but between 1 and 100, inclusive, and processing is to continue until end of file is reached or until the maximum number of pairs have been input (or an error occurs). 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:

   submit itec320-01 pairings.adb
Grading criteria: When grading I will check at least the following specifications:
Dr. Okie's Home Page,
Last modified on Thursday, 24-Sep-2009 08:58:57 EDT