, , 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 penalty.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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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 penalty.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

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 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY