Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length. Function Specifications: • Name: tuneSimilarity() • Parameters (Your function should accept these parameters IN THIS ORDER): o tune1 (string): The first input tune o tune2 (string): The second input tune • Return Value: The similarity score (double) • The parameters should be two strings of equal length. If they are not equal in length, your function should return 0. • The function should not print anything. • You may assume that the input to tuneSimilarity will always be valid SPN, i.e. you do not have to account for arbitrary strings. --- Examples --- Sample function call tuneSimilarity ("G4E5D4", "G4F4D5") tuneSimilarity ("A0B0C0D0", "D1C1B1A1") tuneSimilarity ("E5E5G5A6G5D5", "E5G5A6G5D5D5") tuneSimilarity ("D5G2", "F7D1E4G4") Expected return value 0.666667 -4 0.333333 0 An example test case for the first sample function call would be: assert (doubles_equal(tuneSimilarity ("G4E5D4", "G4F4D5"), 0.666667)); Your file should be named tuneSimilarity.cpp and should also include a main function that tests your tuneSimilarity function. Once you have finished developing your solution in VSCode you should head over to the CodeRunner on Canvas and paste only your function tuneSimilarity into the answer box for question 4. You do not need to paste your main function into Coderunner. A main function has already been provided for you. You will need to include your main, tuneSimilarity and any other helper functions in the tuneSimilarity.cpp file that you submit to Canvas.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 6PP
icon
Related questions
Question

Use C++ to write this code

Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length.

Function Specifications:

  • Name: tuneSimilarity()
  • Parameters (Your function should accept these parameters IN THIS ORDER):
    • tune1 (string): The first input tune
    • tune2 (string): The second input tune
  • Return Value: The similarity score (double)
  • The parameters should be two strings of equal length. If they are not equal in length, your function should return 0.
  • The function should not print anything.
  • You may assume that the input to tuneSimilarity will always be valid SPN, i.e. you do not have to account for arbitrary strings.

--- Examples ---

Sample function call Expected return value
tuneSimilarity("G4E5D4", "G4F4D5") 0.666667
tuneSimilarity("A0B0C0D0", "D1C1B1A1") -4
tuneSimilarity("E5E5G5A6G5D5", "E5G5A6G5D5D5") 0.333333
tuneSimilarity("D5G2", "F7D1E4G4") 0

An example test case for the first sample function call would be: assert(doubles_equal(tuneSimilarity("G4E5D4", "G4F4D5"), 0.666667));

Your file should be named tuneSimilarity.cpp and should also include a main function that tests your tuneSimilarity function. Once you have finished developing your solution in VSCode you should head over to the CodeRunner on Canvas and paste only your function tuneSimilarity into the answer box for question 4. You do not need to paste your main function into Coderunner. A main function has already been provided for you. You will need to include your main, tuneSimilarity and any other helper functions in the tuneSimilarity.cpp file that you submit to Canvas.

Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length.
Function Specifications:
• Name: tuneSimilarity()
• Parameters (Your function should accept these parameters IN THIS ORDER):
o tune1 (string): The first input tune
o tune2 (string): The second input tune
• Return Value: The similarity score (double)
• The parameters should be two strings of equal length. If they are not equal in length, your function should return 0.
• The function should not print anything.
• You may assume that the input to tuneSimilarity will always be valid SPN, i.e. you do not have to account for arbitrary strings.
Examples
Sample function call
tuneSimilarity ("G4E5D4", "G4F4D5")
tuneSimilarity ("AOBOCODO", "D1C1B1A1")
tuneSimilarity ("E5E5G5A6G5D5", "E5G5A6G5D5D5")
tuneSimilarity("D5G2", "F7D1E4G4")
Expected return value
0.666667
-4
0.333333
0
An example test case for the first sample function call would be: assert (doubles_equal(tuneSimilarity ("G4E5D4", "G4F4D5"),
0.666667));
Your file should be named tuneSimilarity.cpp and should also include a main function that tests your tuneSimilarity function. Once you have
finished developing your solution in VSCode you should head over to the CodeRunner on Canvas and paste only your function
tuneSimilarity into the answer box for question 4. You do not need to paste your main function into Coderunner. A main function has
already been provided for you. You will need to include your main, tuneSimilarity and any other helper functions in the
tuneSimilarity.cpp file that you submit to Canvas.
Transcribed Image Text:Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length. Function Specifications: • Name: tuneSimilarity() • Parameters (Your function should accept these parameters IN THIS ORDER): o tune1 (string): The first input tune o tune2 (string): The second input tune • Return Value: The similarity score (double) • The parameters should be two strings of equal length. If they are not equal in length, your function should return 0. • The function should not print anything. • You may assume that the input to tuneSimilarity will always be valid SPN, i.e. you do not have to account for arbitrary strings. Examples Sample function call tuneSimilarity ("G4E5D4", "G4F4D5") tuneSimilarity ("AOBOCODO", "D1C1B1A1") tuneSimilarity ("E5E5G5A6G5D5", "E5G5A6G5D5D5") tuneSimilarity("D5G2", "F7D1E4G4") Expected return value 0.666667 -4 0.333333 0 An example test case for the first sample function call would be: assert (doubles_equal(tuneSimilarity ("G4E5D4", "G4F4D5"), 0.666667)); Your file should be named tuneSimilarity.cpp and should also include a main function that tests your tuneSimilarity function. Once you have finished developing your solution in VSCode you should head over to the CodeRunner on Canvas and paste only your function tuneSimilarity into the answer box for question 4. You do not need to paste your main function into Coderunner. A main function has already been provided for you. You will need to include your main, tuneSimilarity and any other helper functions in the tuneSimilarity.cpp file that you submit to Canvas.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning