Question: Write a function called tuneSimilarity that computes the similarity score as described above for two tunes of equal length. Function Specifications: The function name: tuneSimilarity

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

Function Specifications:

The function name: tuneSimilarity

Parameters (Your function should accept these parameters IN THIS ORDER):

string tune1: The first input tune

string tune2: 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.

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!