Assume , , and have been included and main() looks like this: *attached image 1* The penalty.txt file contains the following data for 10 hockey players: The number of penalty minutes the player had in his career (integer) The number of seasons the player played (integer) The name of the player (string, more than one word) NOTE: There are 10 lines of data in the file, so all three data items for each player are on the same line. I wish I could attach the txt file but it looks exactly like this : 3971 14 Tiger Williams 3565 19 Dale Hunter 3515 17 Tie Domi 3381 17 Marty McSorley 3300 17 Bob Probert 3207 15 Rob Ray 3149 17 Craig Berube 3146 16 Tim Hunter 3043 13 Chris Nilan 2970 18 Rick Tocchet Create code that would be a part of main() that does the following: If the penalty.txt file fails to open, display a message saying the file could not be opened. Otherwise, use a while loop to store each number of penalty minutes, years played, and name in their respective variables, use the data in a sentence, and store that sentence in the badboys.txt file. Close both files at the end of the program. The output should look similar to this: *attached image 2*   Thank you, I really need help with this.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Assume <iostream>, <fstream>, and <string> have been included and main() looks like this:

*attached image 1*

The penalty.txt file contains the following data for 10 hockey players:

  • The number of penalty minutes the player had in his career (integer)
  • The number of seasons the player played (integer)
  • The name of the player (string, more than one word)
    • NOTE: There are 10 lines of data in the file, so all three data items for each player are on the same line.

I wish I could attach the txt file but it looks exactly like this :

3971 14 Tiger Williams

3565 19 Dale Hunter

3515 17 Tie Domi

3381 17 Marty McSorley

3300 17 Bob Probert

3207 15 Rob Ray

3149 17 Craig Berube

3146 16 Tim Hunter

3043 13 Chris Nilan

2970 18 Rick Tocchet

Create code that would be a part of main() that does the following:

If the penalty.txt file fails to open, display a message saying the file could not be opened.
Otherwise, use a while loop to store each number of penalty minutes, years played, and name in their respective variables, use the data in a sentence, and store that sentence in the badboys.txt file.
Close both files at the end of the program.
The output should look similar to this:

*attached image 2*

 

Thank you, I really need help with this.

ifstream in4;
ofstream out4;
int mins, seasons;
string player;
in4.open ("penalty.txt") ;
out4.open ("badboys.txt");
Transcribed Image Text:ifstream in4; ofstream out4; int mins, seasons; string player; in4.open ("penalty.txt") ; out4.open ("badboys.txt");
badboys - Notepad
File Edit Format View Help
|| Tiger Williams had 3971 penalty minutes over 14 NHL seasons.
Dale Hunter had 3565 penalty minutes over 19 NHL seasons.
Tie Domi had 3515 penalty minutes over 17 NHL seasons.
Marty McSorley had 3381 penalty minutes over 17 NHL seasons.
Bob Probert had 3300 penalty minutes over 17 NHL seasons.
Rob Ray had 3207 penalty minutes over 15 NHL seasons.
Craig Berube had 3149 penalty minutes over 17 NHL seasons.
Tim Hunter had 3146 penalty minutes over 16 NHL seasons.
Chris Nilan had 3043 penalty minutes over 13 NHL seasons.
Rick Tocchet had 2970 penalty minutes over 18 NHL seasons.
Ln 1, Col 1
100%
Windows (CRLF)
UTF-8
Transcribed Image Text:badboys - Notepad File Edit Format View Help || Tiger Williams had 3971 penalty minutes over 14 NHL seasons. Dale Hunter had 3565 penalty minutes over 19 NHL seasons. Tie Domi had 3515 penalty minutes over 17 NHL seasons. Marty McSorley had 3381 penalty minutes over 17 NHL seasons. Bob Probert had 3300 penalty minutes over 17 NHL seasons. Rob Ray had 3207 penalty minutes over 15 NHL seasons. Craig Berube had 3149 penalty minutes over 17 NHL seasons. Tim Hunter had 3146 penalty minutes over 16 NHL seasons. Chris Nilan had 3043 penalty minutes over 13 NHL seasons. Rick Tocchet had 2970 penalty minutes over 18 NHL seasons. Ln 1, Col 1 100% Windows (CRLF) UTF-8
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,