Question: Patrick is obsessed with the Toronto Maple Leafs (a well known local hockey team). He keeps data of all the players on the team in

Patrick is obsessed with the Toronto Maple Leafs (a well known local hockey team). He keeps data of all the players on the team in a text file. Information on each player is stored as different lines in his text file. Each line is a string formatted as: The jersey number of the player which is either a single or double digit number. The position they play of either "forward", "defenseman", and "goalie". The average annual salary of the player as a number in brackets. Each of the 3 pieces of data is separated by a comma (",") and nothing else. As an example, the player Auston Matthews has the jersey number 34, plays forward, and has an average annual salary of $11,634,000. Information on this player is stored as the string "34,forward,(11634000)" Patrick has asked Barbara to write a program to read in each line to do some team analysis. Unfortunately, neither Patrick nor Barbara bothered to read about the Design Recipe and the importance of contracts. Since no contract was established, Barbara just assumed her program would read in lines where a space would separate pieces of data instead of commas and no data would be in brackets. As an example, Barbara's program would accept the string "34 forward 11634000" Write a function data-change that comsumes a string that is a line from Patrick's text file and produces a string that can be used as input in Barbara's program. (Don't be like Patrick and Barbara! Please apply the Design Recipe!) Some examples: (data-change "3,defenseman,(2000000)") produces "3 defenseman 2000000" (data-change "50,goalie,(925000)") produces "50 goalie 925000"Patrick is obsessed with the Toronto Maple Leafs (a well known local

Question 2: Data Formatting Patrick is obsessed with the Toronto Maple Leafs TORONTO (a well known local hockey team). He keeps data of all the players on the team in a text file. Information on each player is stored as different lines in his text file. Each line is a string formatted as: 1. The jersey number of the player which is either a single or double digit number. 2. The position they play of either "forward", "defenseman", and "goalie". 3. The average annual salary of the player as a number in brackets. 4. Each of the 3 pieces of data is separated by a comma (",") and nothing else. As an example, the player Auston Matthews has the jersey number 34, plays forward, and has an average annual salary of $11,634,000. Information on this player is stored as the string "34,forward,(11634000)" Patrick has asked Barbara to write a program to read in each line to do some team analysis. Unfortunately, neither Patrick nor Barbara bothered to read about the Design Recipe and the importance of contracts. Since no contract was established, Barbara just assumed her program would read in lines where a space would separate pieces of data instead of commas and no data would be in brackets. As an example, Barbara's program would accept the string "34 forward 11634000" Write a function data-change that comsumes a string that is a line from Patrick's text file and produces a string that can be used as input in Barbara's program. (Don't be like Patrick and Barbara! Please apply the Design Recipe!) Some examples: (data-change "3, defenseman, (2000000)) produces "3 defenseman 2000000" (data-change "50, goalie, (925000)") produces "50 goalie 925000" Question 2: Data Formatting Patrick is obsessed with the Toronto Maple Leafs TORONTO (a well known local hockey team). He keeps data of all the players on the team in a text file. Information on each player is stored as different lines in his text file. Each line is a string formatted as: 1. The jersey number of the player which is either a single or double digit number. 2. The position they play of either "forward", "defenseman", and "goalie". 3. The average annual salary of the player as a number in brackets. 4. Each of the 3 pieces of data is separated by a comma (",") and nothing else. As an example, the player Auston Matthews has the jersey number 34, plays forward, and has an average annual salary of $11,634,000. Information on this player is stored as the string "34,forward,(11634000)" Patrick has asked Barbara to write a program to read in each line to do some team analysis. Unfortunately, neither Patrick nor Barbara bothered to read about the Design Recipe and the importance of contracts. Since no contract was established, Barbara just assumed her program would read in lines where a space would separate pieces of data instead of commas and no data would be in brackets. As an example, Barbara's program would accept the string "34 forward 11634000" Write a function data-change that comsumes a string that is a line from Patrick's text file and produces a string that can be used as input in Barbara's program. (Don't be like Patrick and Barbara! Please apply the Design Recipe!) Some examples: (data-change "3, defenseman, (2000000)) produces "3 defenseman 2000000" (data-change "50, goalie, (925000)") produces "50 goalie 925000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!