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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education