Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE 100 Principles of Programming with C++ Lab 5 :: 5 pts 4 Software Requirements A text file named stats-season.txt contains season statistics for a

image text in transcribed

CSE 100 Principles of Programming with C++ Lab 5 :: 5 pts 4 Software Requirements A text file named stats-season.txt contains season statistics for a basketball team in the format illustrated by this example: 23 88 F.Flintstone 190 50 82 27 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 17 26 58 19 29 316 74 37 S.Skwigelf 18 19 43 18 25 3 9 59 20 T.Wartooth 22 19 59 23 40 7 23 68 46 end G.Jetson The contents of each column from left to right is, Name GP FGM FGA FTM FTA THREEM THREEA PTS REBS The player's name (a string). Games played an integer). Field goals made an integer). Field goals attempted (an integer). Free throws made (an integer). Free throws attempted (an integer). Three point field goals made an integer). Thee point field goals attempted (an integer). The total points scored an integer). The total rebounds (an integer). The last line of the file must contain the word "end". As team statistician, your job is to write a C++ program which reads stats- season.txt, calculates the per game statistics for each player, and writes the per game statistics to an output file named stats- game.txt. The per game statistics that shall be calculated are, PPG RPG FGP FTP THREEP Points per game which is PTS divided by GP. Rebounds per game which is REBS divided by GP. Field goal percentage which is FGM divided by FGA. Free throw percentage which is FTM divided by FTA. Three point field goal percentage which is THREEM divided by THREEA. For the example stats-season.txt input file, the contents of stats-game.txt will be, Name GP PPG RPG FG% FT% 3P% F.Flintstone 23 11.0 4.3 0.463 0.610 0.365 B.Rubble 23 10.4 4.1 0.401 0.849 0.286 W.Flintstone 14 10.1 5.9 0.554 0.630 0.000 H.Simpson 23 9.4 6.2 0.653 0.579 0.333 *** N.Flanders 23 7.2 2.2 0.449 0.882 0.407 M N.Explosion 23 7.0 2.7 0.486 0.643 0.484 K.Broflovski 21 6.0 1.8 0.310 0.722 0.276 E.Cartman 18 4.6 1.2 0.424 0.833 0.459 G.Jetson 17 4.4 2.2 0.448 0.655 0.188 S.Skwigelf 18 3.3 1.1 0.442 0.720 0.333 T.Wartooth 22 3.1 2.1 0.322 0.575 0.304 Note how the output is aligned in columns. This is accomplished by outputting each value in a field of a specific width using the setw() stream manipulator (study the comments in the code). Note that PPG and RPG are printed with 1 digit after the decimal point and all percentages are displayed with 3 digits after the decimal point. The names are printed left-justified in a column and the numerical values are printed right-justified in each column. This is accomplished with the left and right stream manipulators

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago