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.
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");](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fad3ee529-81b1-486a-8459-b4eea2f68af5%2F53180c76-3127-4210-9ddf-c49519d792bf%2Fhcd9kp7_processed.jpeg&w=3840&q=75)
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fad3ee529-81b1-486a-8459-b4eea2f68af5%2F53180c76-3127-4210-9ddf-c49519d792bf%2Fqhlu3l_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)