Submit in the normal way, being sure to put your files in a directory called
In this lab, you’re going to analyze some sports statistics that I copied from here and here. The files you want are basketball.txt and baseball.txt. Download them now and save them to your lab directory.
Have a look at the two files you just downloaded. Something we clearly should be able to do with these files is write a program where the user enters a heading (like 3P%), and get back which team had the highest number for that column, and the value in that column:
We’re going to write this program, in such a way that it will work for either file. By working on solving smaller problems along the way, we can build up gradually to a full solution.
Here are the steps we’re going to follow in a file called
// get a filename and column heading from the user // figure out which column has that header //for each line // get that team's name // get that team's value at that column // track the largest value seen so far // print out the team name and value which was the largest
For this problem, pick small chunks to work on at a time, then combine those chunks to make a full program.
- In case of a tie value in the selected field, your program should output the name of the first team in the file with the maximum value for that field.
- You can assume that the second line of the file always starts with the number 1.
- You can assume that the file always has 30 teams in it.
The rest of this lab is optional for your enrichment and enjoyment. Be sure to work on this only after getting everything else perfect. You should still submit this work, but make sure it doesn't break any of the parts you already had working correctly!
Actually, there is one way in which I modified the files above: I replaced space characters in the team names with underscores
Hint: you may have to read ahead a bit in the Unit 4 notes in order to complete this part.