QuestionDetails: C++ programming I need help counting consonants, digits, andsen
ID: 3610693 • Letter: Q
Question
QuestionDetails: C++ programming I need help counting consonants, digits, andsentences in a data file. Example Program output Enter inputfile name data09 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 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;
}
QuestionDetails: C++ programming I need help counting consonants, digits, andsentences in a data file. Example Program output Enter inputfile name data09 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 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; int main() { ifstream infile; //input filestream variable string FileName; //variable to hold file name int count,prevcount=0,max=50,cons=0,digit=0,sent=0,i,j; string word; bool notfirst=false,firstword=true; char punct[]={'.','!','?'}; charconsti[]={'B','C','D','F','G','H','J','K','L','M','N','P', 'Q','R','S','T','V','W','X','Y','Z'}; coutword; while(infile) {count=word.length(); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.