Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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"image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions