CSE100 Principles of Programming with C++ Lab 5 :: 5 pts
1 Instructions You may work in pairs (that is, as a group of two) with a partner on this lab project if you wish or you may work alone. If you work with a partner, only submit one lab project with both of your names in the source code file to Blackboard for grading; you will each earn the same number of points. What to hand in, and by when, is discussed in Section 5; read it.
2 Lab Objectives After completing this assignment the student should be able to:
● Complete all of the objectives of the previous lab projects. ● Write function definitions, call functions, pass parameters, define local variables. ● Open a text file for reading/writing and read/write strings and numbers from/to the text file.
3 Prelab Exercises ● First, skip to Section 4 and read the lab project software requirements. Then come back here. ● Create a new Code::Blocks C++ project named Lab05. ● Navigate to the course website and download the Lab05.cpp file. This file is a template containing most of the code for the lab
project, but in various places, the code has not been completed. Your job shall be to complete the code by reading the comments and writing proper C++ code in the locations indicated by ??? symbols. Follow the instruction in Steps 28 through 32 of the Code::Blocks tutorial1 to add Lab05.cpp to your Code::Blocks project.
● Navigate to the course website and download the stats-season.txt file. This program will read input data from this file and will write data to an output file named stats-game.txt. Copy stats-season.txt to your Code::Blocks Lab05 project folder. For example, when you created your Lab05 project, if you specified C:\cse100\Lab05 as the project folder, then copy stats-season.txt to C:\cse100\Lab05.
● When you run your program, you will see the output window appear, but nothing of substance will be displayed in it. This is because the output is being sent to the output file named stats-game.txt rather than to the output window. To know if your program worked correctly, you need to open the output file and examine its contents. Click File | Open on the main menu. In the Open dialog, navigate to your project directory C:\cse100\Lab05 where you should see a file named stats-game or possibly stats-game.txt. Click on that file name and then click the Open button. Verify the output file contains the correct contents.
4 Lab Exercise A text file named stats-season.txt contains season statistics for a basketball team, e.g.,
Name GP FGM FGA FTM FTA 3M 3A PTS REB F.Flintstone 23 88 190 50 82 27 74 253 100 B.Rubble 23 85 212 45 53 24 84 239 94 W.Flintstone 14 56 101 29 46 0 1 141 82 H.Simpson 23 77 118 62 107 1 3 216 143 N.Flanders 23 57 127 15 17 37 91 166 51 N.Explosion 23 53 109 9 14 46 95 161 63 K.Broflovski 21 31 100 57 79 8 29 127 38 E.Cartman 18 28 66 10 12 17 37 83 22 G.Jetson 17 26 58 19 29 3 16 74 37 S.Skwigelf 18 19 43 18 25 3 9 59 20 T.Wartooth 22 19 59 23 40 7 23 68 46
Where the contents of each column is,
Name The players name, formatted as I.s where I is the initial of the player’s first name and s is the player’s surname. GP Games played. FGM Field goals made. FGA Field goals attempted. FTM Free throws made. FTA Free throws attempted. 3M Three point field goals made. 3A Thee point field goals attempted. PTS Points (the total points scored in the season). REB Rebounds.
As team statistician, your job is to write a C++ program which reads stats-season.txt, calculates per game statistics, and writes the per game statistics to an output file named stats-game.txt. The per game statistics that shall be calculated are,
(c) Burger :: Computer Science & Engineering :: Arizona State University Page 1
There are no bids yet.
All Rights Reserved, Dataedy.com 2020