Practice Problems for

IC210 Final Practicum

 

NOTE: the final practicum may consist of one large problem or two smaller problems. Some practice problems are given below.

 

Note that as per the course policy, you may only use your notes, the official class notes from the course webpage, or your textbook for the actual practicum, and that you may not receive help from anyone.

 

Problem 1: 

Write a program that reads in a data file of student first names, last names and quiz scores. Print out the students from highest grade to lowest, where within a group with the same quiz grade, students are printed out alphabetically by last name. Your program must use a struct for Student information as well as overload operator>> and operator<<  for your struct.

The data file will start by stating how many students there are, as per the example below. Your program must work for any data file in this format, regardless of how many entries! The data file is here.

final2data.txt

program run

10 students
 
Jeff Jones 9
Anne Aimes 7
Steve Smith 10
Helen Huber 8
Arthur Adams 8
Zeke Zook 9
George Gomez 10
Tom Tate 7
Donna Doyle 8
Ed Error 7
Enter file name: final2data.txt
George Gomez 10
Steve Smith 10
Jeff Jones 9
Zeke Zook 9
Arthur Adams 8
Donna Doyle 8
Helen Huber 8
Anne Aimes 7
Ed Error 7
Tom Tate 7

SOLUTION

 

Problem2:

Write a program that reads in hockey stats from a file. The program should work for any file in the correct format and should prompt the user for the file name. Files in the correct format have the number of players on the first line.  The second line contains column headers. Each file will have six columns: name (NAME), games played (GP), goals (G), assists (A), points (P) and shots (S). Each line after that has player statistics.  You must use a two dimensional array.  The actual data file is here.

Example:

5
NAME             GP   G    A    P    S
JASON SPEZZA     24   14   32   11   63
ILYA KOVALCHUK   25   17   19   35   107
PETER FORSBERG   21   8    31   39   50
LADISLAV NAGY    26   12   18   29   57
VACLAV PROSPAL   28   13   20   33   73

Your program should read the file’s player statistics (names are not statistics) into a two dimensional array. Once the file is correctly read you should provide a user prompt. If the user enters a column header your program should print, to the screen, the last name of the player with the highest value for that statistic along with the value. If the user enters the string “name” followed by a player’s last name the program should print that player’s full name followed by his statistics. The program should then return to a prompt and continue doing so until the user indicates she wants to quit.

Your output should look like the following (user input shown in red):

 

Enter the statistics file name > hockey.txt

HOCKEY STATS > NAME ARMSTRONG

                NAME    GP      G       A       P       S

        DEREK ARMSTRONG 18      3       8       46      26

 

HOCKEY STATS > GP

        JAGR    28

 

HOCKEY STATS > G

        HEATLY  19

 

HOCKEY STATS > A

        SPEZZA  32

 

HOCKEY STATS > P

        ARMSTRONG  46

 

HOCKEY STATS > S

        SUNDIN  143

 

HOCKEY STATS > QUIT

 

SOLUTION: