Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a c++ program that does the following: 1. reads the name of a text file f

ID: 3629487 • Letter: I

Question

I need a c++ program that does the following:

1. reads the name of a text file from a user
2. opens the text file
3. read the contents of the text file
4. uses the toupper function to convert the letters to upper case (or uses the tolower function to convert the letters to lower case)
5. counts the number of vowels in the text file
6. counts the number of consonants in the text file
7. write the vowel count and consonant count to a second file

The vowels are a, e, i, o, and u.
The consonants are the letters that are not vowels.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <fstream>
using namespace std;
int main()
{char filename[80];
char input;
ifstream in;
ofstream out;
int vowel=0,cons=0;
cout<<"Enter name of your input file: ";
cin>>filename;
in.open(filename);
if(in.fail())
     {cout<<"input file did not open please check it ";
     system("pause");
     return 1;
     }
cout<<"Enter name of your output file: ";
cin>>filename;
out.open(filename);
in>>input;
while(in)
{if(isalpha(input))
    {input=toupper(input);
     switch(input)
         {case 'A': case 'E': case 'I': case 'O': case 'U': vowel++; break;
         default: cons++;
         }
     }
in>>input;
}
out<<"vowel count: "<<vowel<<endl;
out<<"consonant count: "<<cons<<endl;
in.close();
out.close();
system("pause");   
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote