C++ programming I need help counting consonants, digits, andsentences in a data
ID: 3610708 • Letter: C
Question
C++ programming I need help counting consonants, digits, andsentences in a data file. I also have to search for thelongest string in the file and count how many times a search stringis found Example Program output Enter inputfile name data09 Enter search string ill The reformatted content of data09 is: Jack and Jill went up the hIll 2 fetch a pail ofstill water. Jack fell down and broke his crown
and Jill came tumbling after! willjillbeill? Consonants: 76 Digits: 1 Sentences: 3 # of times ill found: 6
Longest word: willjillbeill? the ill in hIll should not becounted because the "i" is capitalized data09 is a filestream. *I am not allowed to usearrays I need to add it to my program. This is my program sofar: #include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
ifstream infile; //input filestream variable
string FileName; //variable to hold file name
int count,prevcount=0,max=50;
string word;
bool notfirst=false,firstword=true;
cout<<"Enter input file name"<<endl;
cin>>FileName;
infile.open(FileName.c_str());
infile>>word;
while(infile)
{count=word.length();
if(count+prevcount>max)
{cout<<endl;
prevcount=0;
notfirst=false;
}
else
notfirst=true;
prevcount+=count+1;
if(notfirst&&!firstword)
cout<<" ";
firstword=false;
cout<<word;
infile>>word;
}
cout<<endl;
return 0;
} C++ programming I need help counting consonants, digits, andsentences in a data file. I also have to search for thelongest string in the file and count how many times a search stringis found Example Program output Enter inputfile name data09 Enter search string ill The reformatted content of data09 is: Jack and Jill went up the hIll 2 fetch a pail of
still water. Jack fell down and broke his crown
and Jill came tumbling after! willjillbeill? Consonants: 76 Digits: 1 Sentences: 3 # of times ill found: 6
Longest word: willjillbeill? the ill in hIll should not becounted because the "i" is capitalized data09 is a filestream. *I am not allowed to usearrays I need to add it to my program. This is my program sofar: #include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
ifstream infile; //input filestream variable
string FileName; //variable to hold file name
int count,prevcount=0,max=50;
string word;
bool notfirst=false,firstword=true;
cout<<"Enter input file name"<<endl;
cin>>FileName;
infile.open(FileName.c_str());
infile>>word;
while(infile)
{count=word.length();
if(count+prevcount>max)
{cout<<endl;
prevcount=0;
notfirst=false;
}
else
notfirst=true;
prevcount+=count+1;
if(notfirst&&!firstword)
cout<<" ";
firstword=false;
cout<<word;
infile>>word;
}
cout<<endl;
return 0;
}
Explanation / Answer
please rate - thanks #include #include #include #include using namespace std; bool ispunct(char); bool iscons(char); int main() { ifstream infile; //input filestream variable string FileName; //variable to hold file name intcount,prevcount=0,max=50,con=0,digit=0,sent=0,ill=0,large=0; string word,largest; string:: iterator it; string::size_type pos; char ch; bool notfirst=false,firstword=true; coutword; while(infile) {count=word.length(); if(count>large) {large=count; largest=word; } if(count+prevcount>max) {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.