Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming 3. Please submit the following files: email2-algorithm.txt email2.cpp and email2.txt (program saved as text file) 1. modify email1-algorithm.txt to create email2-algorithm.txt to prompt

C++ Programming

3. Please submit the following files: email2-algorithm.txt email2.cpp and email2.txt (program saved as text file)

1. modify email1-algorithm.txt to create email2-algorithm.txt to prompt the user for the input and output filenames, open and read the input file, and output to the console the lines that contain the character @. If a line contains the character @ more than once, it should be output once for each. If a line contains no @ at all, it should NOT be output.

2. Write email2.cpp from email2-algorithm.txt The program should prompt the user for the input and output filenames, open and read the input file, and output to the console the lines that contain the character @. If a line contains the character @ more than once, it should be output once for each. If a line contains no @ at all, it should NOT be output.

Use an EOF loop to process the input file. Adapt the for-loop from the nsaEncoder.cpp program, to traverse each line that you input. In the loop, test each character in the line to see if equals the character @, and if it does, output the line to the console, and continue through the rest of the line, looking for more @'s.

Here are some guidelines:

If you open the output file, you are not doing this right. If you do not have nested loops, you are not doing this right. If you do not process the text a line at a time, you are not doing this right. If you do not using the for-loop from the nsaEncoder.cpp, you are not doing this right. If you use pointers or char arrays or C-style coding or C-library functions, except for ones demonstrated in our textbook, you are not doing this right. If you do not create your own input files with which to test your program, you are not doing this right. If you do not test your program with the ten .txt files provided in the project writeup, you are not doing this right. Compile and run the program. Submit the source file to the class website for credit.

Program I/O. The program should prompt the user for the input and output filenames, and then output the input file's lines to the console with the character @, once per occurance. There is NO file output in this version.

Example. Your program's console I/O should look something like this, (excluding your program introduction information):

Enter input filename [default: fileContainingEmails.txt]: x.txt Enter output filename [default: x.txt]: y.txt

input filename: x.txt

output filename: y.txt

press any key to continue:

--------------------------------------------------------------------------

email1:

/** C ++ program that prompts user to enter input file and press enter and output file or press enter. Then print input and output file names to console. */ //email1.cpp #include #include using namespace std; //main funciton int main() {

//set default input and output file names string defaultInputFile=\"fileContainingEmails.txt\"; string defaultOutputFile=\"copyPasteMyEmails.txt\"; //set enterkey =false bool enterKey =false; string userInputFile; string userOutputFile;

//prompt for input file name cout\"enter> //read input file name getline(cin,userInputFile);

//check if user press an enter key if(userInputFile.empty()) enterKey=true;

if(enterKey) userInputFile=defaultInputFile;

enterKey=false;

//prompt for output file name cout\"enter> //read input file name getline(cin,userOutputFile);

//check if user press an enter key if(userOutputFile.empty()) enterKey=true;

//if enterkey is true if(enterKey) //set defaultoutputfile to useroutputfilename userOutputFile=defaultOutputFile; //print input and output file names cout\"input> cout\"output>

system(\"pause\"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Add in the indicated base. A73416 + 128B16

Answered: 1 week ago