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

Note: Declare filestream variables and open files in main(). Input: Each line in

ID: 3757541 • Letter: N

Question

Note: Declare filestream variables and open files in main(). Input: Each line in the input file contains a sentence in English text. The number of lines in the input file is not known. The program processes one sentence at a time; the entire sentence must be input into a single string variable Processing: The program will remove all vowels (uppercase and lowercase) from the input string, producing a (usually shorter) string which is the same as the original string except that the vowels are missing. Output: Output is to a file. For each input string, the input string itself is on the first line, and on the line below the first line, the string with no vowels appears. There is a blank line next, before the output of the next string results. Function Requirements: 1. Use the Boolean function isVowel to test whether a character is a vowel. 2. Write a value-returning function which processes a string and produces and returns the string without vowels. 3. Write a void function to do output of an input string, the result string, and a blank line. (Since it is doing file output, the function will need a reference parameter for the output stream variable: ofstream&) Follow Program Guidelines for Header, comments, and spacing.

Explanation / Answer

#include <iostream>

#include <string>

#include <fstream>

using namespace std;

bool isVowel(char ch)

{

if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' ||

ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')

return true;

return false;

}

string modstring(string str)

{

string str2;

int i;

for(i=0;i<str.size();i++)

{

if(!isVowel(str[i]))

str2+=str[i];

}

return str2;

}

void output(string str,ofstream &fout)

{

string str2;

str2=modstring(str);

fout<<str<<endl;

fout<<str2<<endl;

fout<<endl;

}

int main()

{

ifstream fin;

ofstream fout;

string line;

fin.open("input.txt");

fout.open("output.txt");

while(!fin.eof())

{

getline(fin,line);

output(line,fout);

}

fin.close();

fout.close();

}

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