Reading level C Visual StudioSolutioninclude include include
Reading level C++ Visual Studio
Solution
#include <iostream>
#include <cstdlib>
#include <fstream>
int IsSentenced(char *);
int countSyllables(char *);
int wordCount(char *);
using namespace std;
int main (int argc, char* argv[]) {
char c;
int sent_cnt = 0;
int syllables_cnt = 0;
int wrds_cnt = 0;
ifstream inhj;
inhj.open(argv[1]);
while (not (inhj.eof())) {
inhj.get(c);
sent_cnt = sent_cnt + IsSentenced(c);
syllables_cnt = syllables_cnt + countSyllables(c);
wrds_cnt = wrds_cnt + wordCount(c);
}
cout << \"Words : \" << wrds_cnt << endl;
cout << \"Sylables: \" << syllables_cnt << endl;
cout << \"Number of Senetnces \" << sent_cnt << endl;
double index= 206.835 - (1.015 * (double(wrds_cnt) / double(sent_cnt))) - (84.6 * (double(syllables_cnt) / double(wrds_cnt)));
cout << \"\ Index value is is: \" << 206.835 - (1.015 * (double(wrds_cnt) / double(sent_cnt))) - (84.6 * (double(syllables_cnt) / double(wrds_cnt))) ;
int IsSentenced(char *string1)
{
int sent_cnt = 0;
while(*string1 != \'\\0\'){
if (*string1 == \'.\' || *string1 == \'!\' || *string1 == \'?\'|| *string1 == \';\' ||*string1 == \':\'){
sent_cnt++;
string1++;
}
else {
string1++;
}
}
return sent_cnt;
//cout << numSentence;
}
int countSyllables(char *string2){
int syllables_cnt = 0;
while (*string2 != \'\\0\'){
if (*string2 == \'a\' || *string2 == \'e\' || *string2 == \'i\' || *string2 == \'o\' || *string2 == \'u\' ||
*string2 == \'y\' || *string2 == \'A\' || *string2 == \'E\' || *string2 == \'I\' || *string2 == \'O\' || *string2 == \'U\' || *string2 == \'Y\'){
string2++;
if ((*string2 >= \'a\' || *string2 >= \'A\') || (*string2 <= \'z\' || *string2 <= \'Z\') || *string2 == \'.\' || *string2 == \'!\' || *string2 == \'?\'|| *string2 == \';\' ||*string2 == \':\'){
syllables_cnt++;
string2++;
}
}
else {
string2++;
}
}
return syllables_cnt;
}
int wordCount(char *string3)
{
int wrds_cnt = 1;
while(*string3 != \'\\0\'){
if (*string3 == \' \'){
string3++;
if(((*string3 >= \'a\' || *string3 >= \'A\') && (*string3 <= \'z\' || *string3 <= \'Z\'))){
wrds_cnt++;
string3++;
}
}
else {
string3++;
}
}
return wrds_cnt;
}

