Need Help

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

This partially works. I need to be able to determine least used alpha char and most commonly used char (exclude nums, spaces) It should read the contents of the file and show following result: The most common letter is x The least common letter is x #include #include #include #include #include #include #include using namespace std; class LetterCounter { public: LetterCounter(); void ReadFile(char *lower_count); void ParseTextAndCountLetters(); void getMinMaxChar(char *minChar, char *maxChar, int *minCount, int *maxCount); ~LetterCounter(); private: FILE *fpt; char line[15]; int frequency[26]; string stext; }; LetterCounter::~LetterCounter() { // empty destructor // } LetterCounter::LetterCounter() { for (int i = 0; i 64 && c *maxCount) { *maxCount = frequency[i]; *maxChar = i + 65; } if (frequency[i] < *minCount) { *minCount = frequency[i]; *minChar = i + 65; } } } int main() { LetterCounter lc; ifstream inFile("c:/letter_count.txt", ios::in); char minChar, maxChar; int minCount, maxCount; minChar = maxChar = minCount = maxCount = 0; lc.ReadFile("c:/letter_count.txt"); lc.ParseTextAndCountLetters(); lc.getMinMaxChar(&minChar, &maxChar, &minCount, &maxCount); printf("\n The most common letter is %c with = %d occurrences", maxChar, maxCount); printf("\n The least common letter is %c with = %d occurrences", minChar, minCount); printf("\nPress a key to exit!!"); getchar(); return 0; }

cp21 · Sep 22, 2015 10:55 AM · 2,590 views

3 Replies

bump

cp21 · Sep 22, 2015 1:25 PM

anyone willing to help here

cp21 · Sep 22, 2015 7:20 PM

not giving up, i know there is someone out there who can help me with this project

cp21 · Sep 23, 2015 8:10 AM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all