Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a C++ program that has the following functions: Reads in English text

ID: 3667796 • Letter: I

Question

Implement a C++ program that has the following functions: Reads in English text of an arbitrary length from the keyboard. Feel free to include this task in the main () function. Identifies the least frequent letter in the above text. Implement a separate function getLeastFreqLetter () for this task. The main () function then calls this function to find out the least frequent letter and its frequency. Calculate the frequency of each unique word (case insensitive). Implement another function countwordFreq () for this task. Words will be separated by spaces and punctuation. You can use the isspace and ispunct functions to detect separators (references here: http://www.cplusplus.com/reference/cctype/isspace/ and http://www.cplusplus.com/reference/cctype/ispunct/). Please define a global class that contains two public fields, a word and its count, for this task. You can then define a vector of this class to store all the unique words and their counts. The main () function will call this function to print out each word and its corresponding frequency. Identify the most frequently occurring word in the paragraph. Implement another stand-alone function getMostFreqWord () for this purpose. This function will be called in main () to identify the most frequent word and its respective frequency. Your program should prompt the person running it to enter text. Once they are done (once they press enter), your program should print out the information detailed above.

Explanation / Answer

//Partial answer. 2 is complete. 3 is yet to be done.

#include <iostream>
#include <ctype.h>

using namespace std;
class Frequency
{
public:
void getLeastFreqLetter(string s);

};

void Frequency::getLeastFreqLetter(string s)
{
int alphabets[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i,leastfrequency,j=0;
char leastfreqchar;
cout<<s.size();
for(i=0;i<s.size();i++)
{
if(((int)s[i] >= 65) && ((int)s[i] <= 90))
++alphabets[(int)s[i]-65];
else if(((int)s[i] >= 97) && ((int)s[i] <= 122))
++alphabets[(int)s[i]-97];
}
leastfrequency=alphabets[j];
leastfreqchar=(char)(j+65);
for(j=1;j<26;j++)
{
if((alphabets[j]!=0) && ((leastfrequency == 0) || (leastfrequency > alphabets[j])))
{
leastfreqchar=(char)(j+65);
leastfrequency=alphabets[j];
}
}
cout<<"Least frequent letter is "<<leastfreqchar<<" and its frequency is "<<leastfrequency<<endl;
  
}

int main()
{
string s,paragraph;
do {
getline(cin, s);
paragraph += s + " ";
} while (s.length() > 0);
getline(cin,s);
cout<<s;
Frequency f;
f.getLeastFreqLetter(paragraph);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote