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

A program that processes an input file and produces an output file is called a f

ID: 3627840 • Letter: A

Question

A program that processes an input file and produces an output file is called a filter. Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opened for output. (It will be assumed that the first file contains sentences that end with a period.) The program will read the contents of the first file and change all the letters other than the first letter of sentences to lowercase. First letter of sentences should be made uppercase. The revised contents should be stored in the second file.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <fstream>
#include <fstream>
using namespace std;
int main()
{string buffer;
char filename[80];
int i;
ofstream out;
ifstream in;
bool first=true;
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);          
getline(in,buffer);
while(in)
{for(i=0;buffer[i]!='';i++)
     { if(isalpha(buffer[i]))
            if(first)  
              {first=false;
               buffer[i]=toupper(buffer[i]);
               }
             else
                buffer[i]=tolower(buffer[i]);        
      else if(buffer[i]=='.')
             first=true;
     
             
              }
             
out<<buffer<<endl;;
getline(in,buffer);
}
out.close();
in.close();
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