Character Analysis Write a program that reads the contents of a file named text.
ID: 3634386 • Letter: C
Question
Character AnalysisWrite a program that reads the contents of a file named text.txt and determines the following:
The number of uppercase letters in the file
The number of lowercase letters in the file
The number of digits in the file
Prompts And Output Labels. There are no prompts-- nothing is read from standard in, just from the file text.txt. Each of the numbers calculated is displayed on a separate line on standard output, preceded by the following prompts (respectively): "Uppercase characters: ", "Lowercase characters: ", "Digits: ".
Could you please help me with this. I appreciate it, i really need it to pass this class, thank you!
Explanation / Answer
#include #include #include using namespace std;const char FileName[] = "text.txt";int main () { string lineBuffer; ifstream inMyStream (FileName); //open my file streamif (inMyStream.is_open()) {//create an array to hold the letter countsint upperCaseCount = 0;int lowerCaseCount = 0; int digitCount = 0;//read the text filewhile (!inMyStream.eof() ){//get a line of text getline (inMyStream, lineBuffer);//read through each letter in the lineBufferchar oneLetter;for( int n=0; n < (int)lineBuffer.length(); ++n ){ lineBuffer[n] ); //get a letterif (oneLetter >= 'A' && && && oneLetterRelated 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.