question archive Write code in c++
Subject:Computer SciencePrice: Bought3
Write code in c++.
Needs code in Main.cpp file for 4 functions. Don't change anything for the function just use my skeleton. Dont change anything in header file just work in main.cpp. instructions are given on the top of function what we need. For reference string just put any sentence. If one letter is case sensitive and other doesn't means they are not same. for example "hell" and "hello" 4 letters matches.
Main cpp file
#include "sentence.h"
#include <iostream>
using namespace std;
//Constructor sets the reference phrase
// reference string can be anything
sentence::sentence(std::string reference)
{
}
//Provide the input to be compared to the reference. Before this
//function is called, the input should be considered an empty string
void sentence::entry(std::string input)
{
}
//Compares the length of the reference to that of the input and
//returns the absolute value of the difference, or 0 if they are the
//same length
int sentence::length_difference()
{
return 0;
}
//Compares the content of the reference to that of the input and
//calculates the accuracy of matching characters. If the two strings
//are identical, accuracy should be 100. However, for each
//corresponding character that does not match in the same location,
//the percentage of corresponding characters should be returned.
//For example, if the reference and input have 10 letters and the input
//matches 8 of the corresponding reference characters, the function
//should return 80. When input does not have the same number of
//characters as the reference, the accuracy should represent the percent
//of matching characters between the shorter and longer strings. For
//example, if one string has 8 characters matching the corresponding
//locations in another string that has 16 characters, the accuracy is 50%.
double sentence::accuracy()
{
return 0;
}
-----------------------------------------------------------------------------
header file
#ifndef _SENTENCE_H_
#define _SENTENCE_H_
#include <string>
/**
* Class for sentence
**/
class sentence
{
private:
public:
//Constructor sets the reference phrase
sentence(std::string reference);
//Provide the input to be compared to the reference. Before this
//function is called, the input should be considered an empty string
void entry(std::string input);
//Compares the length of the reference to that of the input and
//returns the absolute value of the difference, or 0 if they are the
//same length
int length_difference();
//Compares the content of the reference to that of the input and
//calculates the accuracy of matching characters. If the two strings
//are identical, accuracy should be 100. However, for each
//corresponding character that does not match in the same location,
//the percentage of corresponding characters should be returned.
//For example, if the reference and input have 10 letters and the input
//matches 8 of the corresponding reference characters, the function
//should return 80. When input does not have the same number of
//characters as the reference, the accuracy should represent the percent
//of matching characters between the shorter and longer strings. For
//example, if one string has 8 characters matching the corresponding
//locations in another string that has 16 characters, the accuracy is 50.
double accuracy();
};
#endif