CS 312 Assignment 7, Home Field Advantage

NEED TO ADD MORE DATA FILES FOR ANALYSIS OR TAKE DOWN EXPECTED RESULTS FOR THE 4 DATA FILES ON CANVAS.

Programming Assignment 7: Individual Assignment. You must complete this assignment by yourself. You cannot work with anyone else in the class or with someone outside of the class. You may not copy solutions from the world wide web. You are encouraged to get help from the instructional staff.

Placed online: Tuesday, March 8
20 points, ~2% of total grade
Due: no later than 11 pm, Thursday, March 24
General Assignment Requirements

The purpose of this assignment is to implement a program that determines if their is a noticeable home field advantage in various sports. To do the program you will practice the following techniques.

  1. Practice creating a structured program to solve a problem.
  2. Write methods that use parameters.
  3. Use Scanners to process files and lines
  4. Track and calculate statistics for a large data set.
  5. Use the printf method

For this assignment you are limited to the language features in chapters 1 through 6 of the textbook.

Provided Files:

  1. HomeField.java (A shell file with a main method and the header information.)
  2. wbb08s.txt A small sample file with some games from the 2008 - 2009 NCAA Women's College Basketball season. Do not assume the larger files will have the same fixed format as this small sample file. Likewise, the larger data files do not always list the winning team first.
  3. Various larger text files with many games from a season of sport such as Women's College Basketball, Women's College Soccer, and Major League Baseball. These files can be found on Canvas under the assignment 7 page. A big thank you to Professor Ken Massey for allowing me to use the data he has collected and is available here. These files are used to produce the output seen in the sample output files below.

Description: Write a program to prompt the user for the names of file that contain the outcomes of games from a given season in a given sport. The program then determines the number of games played with a home team, the number and percentage of those games the home team won, and the average point difference between the home team and the away team in those games

There are two sample files: homeField1.txt and homeField2.txt Use a diff tool such as the one at this website ( www.quickdiff.com) to ensure your program produces the correct output. Even minor differences in output will cause you to fail grading tests and lose points.

The data files have the following form:

<SPORT>
<SEASON>
<GAME 1>
<GAME 2>
...
<GAME N>

Here is a small example file:

NCAA Women's Basketball
2011 - 2012
2007-11-11 Rice           63 @Winthrop    54 O1
2007-11-11 @S Dakota St   93 UC Riverside 90 O2
2007-11-11 @Texas         92 Missouri St  55
2007-11-11 Tennessee      76 Chattanooga  56
2007-11-11 Mississippi St 76 Centenary    57
2007-11-11 ETSU           75 Delaware St  72 O1 Preseason NIT

After the Sport and Season lines game results are listed, one per line.

Each line with a game result has the following format:

<DATE> <TEAM 1> <TEAM 1 SCORE> <TEAM 2> <TEAM 2 SCORE> <FLAGS> <OPTIONAL INFO>

The flags indicate information such as an overtime game and / or playoff game. The optional information may indicate the tournament of series the game was a part of, or the venue for neutral sites.

The home team for the game, if any is indicated by the @ symbol at the start of the team name. Either team 1 or team 2 could have been the home team.

So for example in the following game Texas (team 1) was the home team:

2007-11-11 @Texas 92 Missouri St 55

and in the follow game Winthrop was the home team:

2007-11-11 Rice 63 @Winthrop 54 O1

The following game had no home team and was played on a neutral site:

2007-11-11 Mississippi St 76 Centenary 57

Your program must:

Approach: As always break the problem up into reasonable parts to provide structure and remove redundancy. Use the Scanner connected to the file to read lines. Process those lines (Strings) with another Scanner that you create for each line.

Divide the program up into methods to provide a structured solution. Some of the methods will be void and others will return values. You will have to make use of parameters, for loops, while loops, String methods, Scanners and if statements.

Use caution when copying and pasting text from word processors. Word processors may alter the characters and cause different results. If you copy and paste text I suggest using a simple text editor.

By way of comparison my solution has 8 methods including the main method. No method is more than 23 total lines including the method header and the closing brace. The program is about 140 lines long including single braces and white space, but not including the large comment at the top.

Hints for using the printf method:

When finished turn in your HomeField.java program via Canvas.

Analysis: Now that we can read from files, you can analyze lots of data. After completing your program you must use the sample file to generate results. For each of the large given files list your results in a comment at the top of your program.

Analyze the results generated by your program. The analysis must be based on results not available in the sample output files. Is there an indication that home field advantage in sports exists? If so how significant is it? Is this true for all sports or just some? Your analysis shall be multiple, well thought out paragraphs. I expect you to use the data and result generated by your program to support your analysis.
 


Checklist: Did you remember to:


Back to the CS 312 homepage.