Stats

As with most team sports, certain statistics can be accumulated during play. For this problem, you are to write a program that reads play descriptions for a volleyball game and produces a report of player and team statistics for one of the teams. Your program will read in a series of input lines that describe a “play” of a volleyball game. Table 1 lists the types of plays that your program will use for input. Key Play H HIT K KILL E ERR B BLOCK D DIG Play Description A hit that was successfully defended by the opponent. A hit that was not successfully defended by the opponent. An erroneous hit that went into the net or out of bounds. A successful defense of a hit at the net. A successful defense of a hit behind the net. Table 1: Real-Time Plays C CHECKIN An indication of the beginning of a new game. The beginning of any game will contain one “CHECKIN” play that lists all the players in the game from one team. R REPORT Command to your program to generate a report. After gen- erating a report, your program should discard all collected play records and begin processing anew on the rest of the input file. Each play (except CHECKIN and REPORT) has exactly one 2-digit player number associated with it. Player digit numbers are limited to 0 through 5 allowing referees to indicate player numbers using 0 to 5 fingers off of each hand. Your program is to compute the following statistics for each player that has participated in any game as well as statistics for the entire team. Descriptions of all statistics that your program is to compute from the collected plays are listed in Table 2. Label Hit % KPG BPG DPG Formula (sum(KILL) − sum(ERR))/ (sum(KILL) + sum(ERR) + sum(HIT)) sum(KILL)/#Games sum(BLOCK)/#Games sum(DIG)/#Games Description Hitting percentage Kills per game Blocks per game Digs per game Sample 0.461 5.613 3.100 2.050 Input Table 2: Computed Statistics Input to your program will consist of a series of input lines each with exactly one play. Column 1 will contain one of the play keys from Table 1. If the play is a REPORT, there is no additional input on the line. If the play is a CHECKIN, there will be a blank in column 2, followed by a single integer (06 ≤ NP ≤ 15) in columns 3 and 4 which indicates the number of players participating in the game. The remainder of the line contains a series of 2-digit (including leading zeros) player numbers (each with

2/4 exactly 1 preceding blank) indicating the players who participated in the game. You can be confident that the CHECKIN is accurate and that no player will be mentioned in any play in that game who does not appear on the preceding CHECKIN line. For the plays HIT, KILL, ERR, BLOCK, and DIG, there will be blank in column 2 and exactly one player number (including leading a leading zero as required) in columns 3 and 4. Note: Read the sample input below by columns. The ‘C’ lines appears splited here by formating reasons. Output Each time your program reads in a “REPORT” play, you should print a report with the following format. The first two lines of each report must contain the following strings each starting in column 1. Player Hit Pct KPG BPG DPG

Your program should then print, for each player who has played in at least one game, a single line in the following format: 55 s0.000 99.999 99.999 99.999 with the lines in ascending order of player number. In the player report line, s is the sign of the hitting percentages and is ’+’ if the hitting percentage ≥ 0.000 and is ’-’ otherwise. Note the hitting percentage should be 0.000 if the user has not made any hits, kills, nor errors. After printing a report for each player, your program should print a single line containing the team statistics in the following format. team s0.000 99.999 99.999 99.999 You can be confident that no statistic’s magnitude will exceed 99.999 in value. After printing the team statistics, your program should print exactly one blank line. Sample Input C 8 01 23 45 54 00 32 10 14 B32 E32 D01 E01 D45 B54 B23 D45 B32 K00 E32 K32 K32 D 23 H14 B 00 E23 D 00 D45 H 10 B45 B 10 B23 B 14 D23 H 14 E23 D 00 E45 K 00 K45 D 00 B25 B 23 K00 K 01 B00 D 01 K14 K 01 D14 E 01 D00 B25 B25 D25 E31 H25 B00 B31 B00 E00 H22 H00 K22 B00 H22 K14 B25 E14 D25 K22 B25 K22 D22 K00 D31 B22 K45 E22 K31 D00 C745 D 01 K 14 D 01 K 23 H 23 B 25 K 25 H 45 B 22 K 01 E 01 R C 61304 40141522 D 04

3/4 D45 D23 D10 K01 H10 E01 D14 K00 D14 K14 B45 D00 B54 B00 D54 K14 D01 E23 D01 K00 H14 K45 K14 B01 H01 B01 H10 K32 H10 K45 B14 K23 D01 C 7 14 B00 00 45 23 D00 31 25 22 B54 H00 E32 K00 K01 K14 H10 K14 H14 H14 E14 B23 E00 B23 D01 K23 H01 H23 B23 D45 Sample Output B00 D00 D14 E22 E00 K45 D23 B14 B23 H25 D00 D14 K14 B45 B45 D14 B14 K14 D22 E00 H00 D23 H23 E23 H45 D45 E00 K45 K45 D23 231401 K45 222511 E45 E01 B25 B45 B25 E01 E25 H11 H31 K11 K22 D14 E31 B14 K31 E14 K22 K45 K22 K22 B31 B22 K31 D45 D45 K45 B22 H14 K22 B14 K23 E22 H00 D23 K31 D11 B45 E11 D45 D11 H22 K25 D00 K22 K00 B22 H25 D01 H31 E01 K31 D11 D31 K14 R Player Hit Pct

KPG BPG DPG 00 +0.176 4.000 01 -0.143 2.500 10 +0.000 0.000 11 +0.000 1.000 14 +0.400 3.667 22 +0.400 4.500 23 +0.000 1.333 25 +0.167 1.000 31 +0.333 5.000 32 +0.000 3.000 45 +0.571 3.333 54 +0.000 0.000 team +0.225 19.333 Player Hit Pct KPG

04 +0.000 0.000 2.000 1.000 4.000 5.000 1.000 4.500 1.000 1.000 0.000 3.000 2.000 2.333 2.500 1.000 2.333 2.333 4.000 1.000 2.000 2.000 2.000 0.000 2.000 3.000 3.000 1.000 16.667 17.667 BPG DPG B 04 B 04 K 14 B 14 B 14 K 14 K 14 K 14 B 14 D 14 D 14 B 14 H 15 D 15 E 15 H 15 H 15 H 15 H 15 E 15 B 22 B 22 K 22 E 22 H 22 K 22 D 40 D 40

4/4 13 +0.000 14 +1.000 15 -0.286 22 +0.250 40 +0.000 team +0.200 0.000 0.000 4.000 4.000 0.000 0.000 2.000 2.000 0.000 0.000 6.000 8.000 0.000 2.000 1.000 0.000 2.000 6.000