CSCE 2004 - Homework 5
Due Date - 11/18/2013 at 11:59 PM

1. Problem Statement:

The primary goal of this programming assignment is to give students practice designing and implementing C++ code to read, write and process ASCII files. You will be given a text file that contains all of the SEC football scores from the 2011 season. Your program must read this ASCII file, extract and print all of the scores for a particular team, determine which team won these games based on their scores, and determine the overall win/loss record for the specified team. These requirements are described in more detail below.

The input file SEC-2011.txt has the scores for each week stored in the following format. Notice that each game record is of the form "score1 team1 score2 team2". To simplify data input/output we have used underscores in school names in place of spaces. To make the ASCII file easier to read by humans, each week's scores are separated by a line full of dashes and the week number.

------- WEEK 1 ----------------------------------------

59	Mississippi_State	14      Memphis
14	Kentucky		3       Western_Kentucky
38	Utah_State		42      Auburn
7	Kent_State		48      Alabama
14	BYU			13      Mississippi
16	Montana			42      Tennessee
7	Missouri_State 		51      Arkansas
3	Florida_Atlantic	41      Florida
37	East_Carolina		56      South_Carolina
14	Elon			45      Vanderbilt
35	Boise_State		21      Georgia
27	Oregon			40      LSU

When the user runs your program. You should prompt them for the name of the team they are interested in. Then you should process the input file to create a summary of all games played by that team and their overall win/loss record. For example, if the user enters "Arkansas" the following should be printed.

1 51 Arkansas 7 Missouri_State
1 52 Arkansas 3 New_Mexico
1 38 Arkansas 28 Troy
0 14 Arkansas 38 Alabama
1 42 Arkansas 38 Texas_A&M
1 38 Arkansas 14 Auburn
1 29 Arkansas 24 Ole_Miss
1 31 Arkansas 28 Vanderbilt
1 44 Arkansas 28 South_Carolina
1 49 Arkansas 7 Tennessee
1 44 Arkansas 17 Mississippi_State
0 17 Arkansas 41 LSU
1 29 Arkansas 16 Kansas_State
Arkansas overall record: 11 wins, 2 losses

For each of the game records, the first value in each row is 1=win or 0=loss. This is followed by the score for selected team, the name of the selected team, the score for the opponent, and finally the name of the opponent. After printing all of the game records, you should print the overall win/loss record for the selected team.

2. Design:

This is a very open ended project because there are many ways to process the input file to produce the output specified above. Since the problem is large and complex, most people are not able to make all of the design decisions before they start implementing a solution. You may want to design, implement and test parts of the solution separately, and based on what you discover, adjust your design of the rest of the program. Several of these design options are described below.

Reading the input file: The input file format above has two types of lines. Some of the lines show the scores and names of the two teams that played. Other lines are blank or contain a line full of dashes and the week number. One of your first tasks is to decide how to read the input file and distinguish one type of line from the other. You have several options to consider. Should you use "din >> score >> name ..." to read each line, or should you use "din.getline(line)" followed by some code to process the line string? Another option is to look at the first character of each line using din.peek(ch) and then decide if it is a score line if it starts with a digit '0' to '9', or skip over the line if it starts with something else. Once you have found a score line, you have two options again. You could process the score lines as you find them, or you could use a "two pass" approach and save all of the score lines in a temporary file, close the file, open the temporary file to process all of the score lines.

Searching for specified team: When the user requests the win/loss record for a team, you need to figure out which of the game records to use. As you may have noticed, about half of the time a team will be in the left column, and half of the time it will be in the right column. Once you have found a record where one of the names match the specified team name, you need to decide if a 1=win or 0=loss should be printed and then print the rest of the score line with the selected team score in the left column.

Calculating the win/loss record: Your final task is to calculate the overall win/loss record for the selected team. Here you need to decide what variables to use, and how/when to update these variables. Hint: the number of wins is equal to the sum of the 1's and 0's in the first column. There are several ways to calculate the number of losses. Just be sure that the #wins + #losses = #games. It is fairly easy to print the overall record once you have #wins and #losses.

3. Implementation:

This time you are not starting with an sample program. You may want to look at the file input/output examples in the source directory to get something to start with. As always, it is very important to add features to your program a little at a time, and print out intermediate results as you perform calculations. With the incremental approach you design one feature at a time, writing comments, adding code, compiling, and debugging. This way, you always have a program that "does something" even if it is not complete.

4. Testing:

Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program with several input values, and save your testing output in text files for inclusion in your project report.

5. Documentation:

When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.

6. Project Submission:

In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "upload" your documentation (a single pdf or txt file), and your C++ program (a single cpp or txt file). Do NOT upload an executable version of your program.

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.