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:
- 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:
- The original pairings
- simulated pairings between the best of A down to the worst of
A against the same range for B
- 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:
- Too many numbers
- Improperly formed pairs (ie odd number of numbers or white space after last value)
- Input that is not a number and not white space
- Score out of range
If any of these errors occur, your program should output an explanatory message 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.
- Define and use a subrange type that you declare
- 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.
- No global variables!
- You must also submit a neat and legible structure chart of your program showing procedures that are
called and information passed.
Output specification:
- Your output should follow the format of the example.
- Your program is to have no prompts.
- There are to be no trailing blanks on the lines.
- There is to be at least one blank immediately following a colon.
- Values should be lined up as shown.
- Floating point values should be output with one decimal place.
- A blank line should appear between information on pairings.
Other points:
-
Your program should be called
pairings.adb
-
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 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:
- Use of procedure with proper parameter(s).
- Use of function with proper parameter(s).
- Use of subrange type.
- Main procedure only contains a few statements.
- No global variables.
- Program is robust: it handles erroneous input with an appropriate error message.
- Proper output format
- 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 Thursday, 24-Sep-2009 08:58:57 EDT