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:
- 2020 Feb 16 05:03:44 PM: Set due date
- 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:
- Calculate and print the results from the original pairings, as in the input
-
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.
- Calculate and print results from pairings of the players in the reduced teams, in the original
order.
- 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.
- 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:
- Valid input is between 2 and 100, inclusive, pairs of integers, each in the range 1 .. 1_000.
- Values in the input will consist of pairs of positive integers, separated by white space.
The first number may be preceded by white space and the final number will NOT be followed by white space.
- For this program, you cannot assume that the input is correct; instead
you are to detect the following errors:
- Too few or too many numbers
- Skill level out of range
- Improperly formed pairs (ie odd number of numbers or white space after last value)
- Input that is not a number and not white space
If any of these errors occur, your program should output a message that explains what error
occurred and then end execution.
Additional requirements:
- Define and use at least one procedure that has at least one
out
or an in out
mode parameter
- Define and use at least one function that has at least one
parameter.
- Make good use of types (ie either range attribute or new subtypes
or new integer types).
- 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.
- The lines in the main routine's exception handler do not count toward the few statements in
the main routine. In other words, the main routine should contain just a few lines of code, and it can also
contain an exception handler.
- No global variables! All communication with subroutines should be through parameters.
Output specification:
- Your output should follow the format of the example.
- Your program is to have no prompts.
- There is to be at least one blank immediately following a colon.
- Values should be lined up in columns
(ie right justified) as shown.
- Floating point values should be output with one place to the right of the
decimal point.
- A blank line should appear between information on pairings.
Other points:
- Notice that "Average A win" means the size of the average win for A. Similarly for B.
- You may use any sort routine that you wish to sort your arrays.
-
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.
-
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:
- Wins, Ties, Averages calculated correctly
- Program is robust: it handles erroneous input with an appropriate error message.
- Proper output format
- Use of procedure, with proper parameter(s).
- Use of function.
- Use of range constraints, subtype, or new numeric type.
- Main procedure contains only a few statements.
- No global variables.
- Correct sort routine
- Correct pairings of players
- Style: Internal and block documentation and use white space
- On time (10% per day late penalty, until when graded)
Dr. Okie's Home Page,
Last modified on