Question: Please write in C++. Uh.. No they are not?! Major League Baseball (MLB) is an American professional baseball organization and the oldest of the major




Please write in C++.
Uh.. No they are not?!
Major League Baseball (MLB) is an American professional baseball organization and the oldest of the major professional sports leagues in the United States. A total of 30 teams play in Major League Baseball and the next MLB is planned to start in April 2021. Your friend is playing fantasy baseball league and is asking your help in choosing their team. Your task is to come up with a program that selects players based on Sabermetrics measures. Sabermetrics or SABRmetrics is the empirical analysis of baseball, especially baseball statistics that measure in-game activity. For the sake of simplicity, let us write a program that chooses 9 players for the team - 5 batters (hitters) and 4 pitchers. The program should ask the user to enter the filenames and read the files with player statistics of batters and pitchers and display the output as mentioned below. Assume there would be at least one batter and one pitcher who satisfy the criteria (explained later). If there are enough players who satisfy the criteria to form a team, then display the selected players information and output "Great, your team is ready!" at the end. If there aren't enough players who satisfy the criteria to form a team, then display the selected players information and output Not enough players who satisfy the criteria to form a team!" at the end. O . If the file cannot be opened, print "Could not open file(s)." Players information is organized in two text files (one for batters and one for pitchers) such that the data corresponding to each player is on one line, with the values separated by commas. You can find examples of the text files you'll be working with on the writeup. Batters (Hitters): Batters are chosen based on a metric known as on-base plus slugging, which is the sum of two Sabermetrics measures-on- base percentage (OBP) and slugging percentage (SLG). These measurements are computed as follows, H+ BB+ HBP OBP = AB + BB+ HBP + SF Here, OBP is On-base percentage (double) His Hits (integer) BB is Bases on Balls (Walks) (integer) HBP is Hit By Pitch (integer) AB is At Bat (integer) SF is Sacrifice fly (integer) SLG (1B) + (2 X 2B) + (3 x 3B) + (4 x HR) AB Here, 1B refers to Singles (integer) 2B refers to Doubles (integer) 3B refers to Triples (integer) HR refers to Home runs (integer) AB refers to At bat (integer) OPS =OBP + SLG Here, OPS is on-base plus slugging (double) OBP is on-base percentage (double) SLG is slugging percentage (double) If the overall score (i.e. on-base plus slugging) is 0.900 or higher, you will select the player in your team. You need to choose 5 such batters for your team in a sequential manner (i.e. you will select the first 5 players whose OPS is 0.900 or higher from the list of players in the input file). Please note that players with an OPS score of O should not be selected. Pitchers: Pitchers are chosen based on Walks plus Hits per Inning Pitched (WHIP). It is computed as follows, BB + H WHIP IP Here, WHIP is Walks plus Hits per Inning Pitched (double) BB is Bases on Balls (Walks) (integer) His Hits (integer) IP is Innings Pitched (double) You will choose the players with the score 1.00 or lower, for our team in the sequential manner (i.e. you will select the first 4 players whose WHIP is 1.00 or lower from the list of players in the input file). Please note that players with WHIP score of O should not be selected. Assume there are at-least 4 pitchers in the input file who qualify our criteria. Finally, you will display the players' names selected along with their information - role of the player (batter or pitcher), team for which they are playing in MLB (see the sample run below). Please note that display all the selected batters first and then display all the selected pitchers. For example: Test Input Result // Sample run 1 batters_sample_1.csv Enter the filename of batters: pitchers_sample_1.csv Enter the filename of pitchers: Selected Players: Anthony Alford, Batter, PIT Jared Walsh, Batter, LAA Hernan Perez, Batter, CHC Jaylin Davis, Batter, SF Joey Rickard, Batter, SF Yimi Garcia, Pitcher, MIA Ryan Sherriff, Pitcher, TB Roberto Osuna, Pitcher, HOU Richard Rodriguez, Pitcher, PIT Great, your team is ready! // Sample run 2 batters_sample_2.csv Enter the filename of batters: pitchers_sample_2.csv Enter the filename of pitchers: Selected Players: Anthony Alford, Batter, PIT Yimi Garcia, Pitcher, MIA Not enough players who satisfy the criteria to form a team! // Sample run 3 fileNot Presenti.csv fileNotPresent2.csv Enter the filename of batters: Enter the filename of pitchers: Could not open file(s). Major League Baseball (MLB) is an American professional baseball organization and the oldest of the major professional sports leagues in the United States. A total of 30 teams play in Major League Baseball and the next MLB is planned to start in April 2021. Your friend is playing fantasy baseball league and is asking your help in choosing their team. Your task is to come up with a program that selects players based on Sabermetrics measures. Sabermetrics or SABRmetrics is the empirical analysis of baseball, especially baseball statistics that measure in-game activity. For the sake of simplicity, let us write a program that chooses 9 players for the team - 5 batters (hitters) and 4 pitchers. The program should ask the user to enter the filenames and read the files with player statistics of batters and pitchers and display the output as mentioned below. Assume there would be at least one batter and one pitcher who satisfy the criteria (explained later). If there are enough players who satisfy the criteria to form a team, then display the selected players information and output "Great, your team is ready!" at the end. If there aren't enough players who satisfy the criteria to form a team, then display the selected players information and output Not enough players who satisfy the criteria to form a team!" at the end. O . If the file cannot be opened, print "Could not open file(s)." Players information is organized in two text files (one for batters and one for pitchers) such that the data corresponding to each player is on one line, with the values separated by commas. You can find examples of the text files you'll be working with on the writeup. Batters (Hitters): Batters are chosen based on a metric known as on-base plus slugging, which is the sum of two Sabermetrics measures-on- base percentage (OBP) and slugging percentage (SLG). These measurements are computed as follows, H+ BB+ HBP OBP = AB + BB+ HBP + SF Here, OBP is On-base percentage (double) His Hits (integer) BB is Bases on Balls (Walks) (integer) HBP is Hit By Pitch (integer) AB is At Bat (integer) SF is Sacrifice fly (integer) SLG (1B) + (2 X 2B) + (3 x 3B) + (4 x HR) AB Here, 1B refers to Singles (integer) 2B refers to Doubles (integer) 3B refers to Triples (integer) HR refers to Home runs (integer) AB refers to At bat (integer) OPS =OBP + SLG Here, OPS is on-base plus slugging (double) OBP is on-base percentage (double) SLG is slugging percentage (double) If the overall score (i.e. on-base plus slugging) is 0.900 or higher, you will select the player in your team. You need to choose 5 such batters for your team in a sequential manner (i.e. you will select the first 5 players whose OPS is 0.900 or higher from the list of players in the input file). Please note that players with an OPS score of O should not be selected. Pitchers: Pitchers are chosen based on Walks plus Hits per Inning Pitched (WHIP). It is computed as follows, BB + H WHIP IP Here, WHIP is Walks plus Hits per Inning Pitched (double) BB is Bases on Balls (Walks) (integer) His Hits (integer) IP is Innings Pitched (double) You will choose the players with the score 1.00 or lower, for our team in the sequential manner (i.e. you will select the first 4 players whose WHIP is 1.00 or lower from the list of players in the input file). Please note that players with WHIP score of O should not be selected. Assume there are at-least 4 pitchers in the input file who qualify our criteria. Finally, you will display the players' names selected along with their information - role of the player (batter or pitcher), team for which they are playing in MLB (see the sample run below). Please note that display all the selected batters first and then display all the selected pitchers. For example: Test Input Result // Sample run 1 batters_sample_1.csv Enter the filename of batters: pitchers_sample_1.csv Enter the filename of pitchers: Selected Players: Anthony Alford, Batter, PIT Jared Walsh, Batter, LAA Hernan Perez, Batter, CHC Jaylin Davis, Batter, SF Joey Rickard, Batter, SF Yimi Garcia, Pitcher, MIA Ryan Sherriff, Pitcher, TB Roberto Osuna, Pitcher, HOU Richard Rodriguez, Pitcher, PIT Great, your team is ready! // Sample run 2 batters_sample_2.csv Enter the filename of batters: pitchers_sample_2.csv Enter the filename of pitchers: Selected Players: Anthony Alford, Batter, PIT Yimi Garcia, Pitcher, MIA Not enough players who satisfy the criteria to form a team! // Sample run 3 fileNot Presenti.csv fileNotPresent2.csv Enter the filename of batters: Enter the filename of pitchers: Could not open file(s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
