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"
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 925000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started