30% More (or just more %)

Background

Yesterday, we learned to use the % operator with strings to create tables of values.  Today, we’re going to continue to practice this technique. Earlier in the year, we worked with data files in the online tutorial. Today, we’re going to revisit the section titled Reading a Data File and edit the program there to display quarterback data in nice columns.

Your Assignment

Visit this link to review the QB data file discussion and the program in ActiveCode 1, which reads and prints the data.  The program is seven lines long and it will stay that way for the most part.  We are going to change one line (#5) and add to a blank line (#2) so that the data will be printed in nice, formatted , right-justified columns using the % operator.  See the image below for an example (click the image to enlarge it):

qbdata-columns

I have put a copy of the QB data on the HS APPS N: drive with the name qbdata.txt.  Save a copy of that file in your H: drive so your program will have access to it.

Program Requirements

  • Copy the program code in ActiveCode 1 from the tutorial site.
  • Change line #2 (the blank one) so that it includes a print statement that displays the columns headers shown in the picture (and detailed in the tutorial).
  • Change line #5 so that in prints the data in nice columns like those in the picture, using the % operator.
  • Create a one-page Word document that includes a program description, your code, and the output (like yesterday).

Hints

  • You have the freedom to choose your column widths for your % operators.  However, common sense dictates that each column must be at least as wide as the longest string displayed in the column.  For example, the last name column needs to be at least as wide as Ben Roethlisberger’s last name.
  • You should use the same values (width numbers) with the % operator in line 2 and line 5 of your program, since the information displayed will be in the same columns.
  • The program will only have seven actual lines, but if line 2 and line 5 get too long, you can wrap them around to a second line if you are careful and hit enter after one of your commas.  Tab the additional wrapped line over at least once.