Question
IN C++ Write a function called tuneSimilarity that computes the similarity score as described in the project instructions for two tunes of equal length. Function
IN C++ Write a function called tuneSimilarity that computes the similarity score as described in the project instructions 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.
Please see the project 1 write up for more details on how to calculate the similarity.
Paste only your function in the answer box! Do not paste main or #includes, just the function.
Hint: Remember when you write a for loop, you can increment the value of the counter variable by any value and not just 1.
For example:
Input | Result |
---|---|
A2B3E2D1 A2D1F2D1 | 1.5 |
A4D2F0E9 D3E1B7 | 0 |
C4F7D1 C4F7D8 | 3 |
A1D3E0 B0E1D4 | -3 |
A1D3E0C6F1 B0G1D4A0D7 | -5 |
A3B4 A3B4 | 3 |
A1D3E0C6F1 B0G1 | 0 |
Step 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