Question

Need this in C++ // Start // Declarations // InputFile inFile1; // InputFile inFile2; // OutputFile...

Need this in C++

// Start

// Declarations

// InputFile inFile1;

// InputFile inFile2;

// OutputFile outFile1

;// num mClientNumber, fClientNumber

// string mClientName, fClientName

// bool atLeastOneFileNotAtEnd = true

// bool inFile1Written = false

// bool inFile2Written = false

// output "File merge processing starting"

// open inFile1 "MaleClients.rtf"

// open inFile2 "FemaleClients.rtf"

// open outFile1 "MergedClients.rtf"

// read mClientNumber and mClientName from inFile1

// read fClientNumber and fClientName from inFile2

// while ( atLeastOneFileNotAtEnd == true )

// if (inFile1 is EOF)// if (inFile2Written == false)

// output fClientNumber, fClientName to Outputfile

// inFile2Written = true// endif// else if (inFile2 is EOF)

// if (inFile1Written == false)

// output mClientNumber, mClientName to Outputfile

// inFile1Written = true

// endif

// else if (mClientNumber < fClientNumber)

// output mClientNumber, mClientName to Outputfile

// inFile1Written = true

// else

// output fClientNumber, fClientName to Outputfile

// inFile2Written = true

// endif

//

//

// if ((inFile1 not EOF) AND (inFile1Written == true))

// read mClientNumber and mClientName from inFile1

// inFile1Written = false

// endif

// if ((inFile2 not EOF) AND (inFile2Written == true))

// read fClientNumber and fClientName from inFile2

// inFile2Written = false

// endif

// if ((inFile is EOF) AND (inFile2 is EOF))

// atLeastOneFileNotAtEnd = false

// endif

// endwhile

// close inFile1

// close inFile2

// close outFile1

// output "Merging Complete"

// Stop

Homework Answers

Answer #1

C++ PROGRAM

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()//main
{
ifstream inFile1;// InputFile inFile1
ifstream inFile2;// InputFile inFile2
ofstream outFile1;// OutputFile outFile1
int mClientNumber, fClientNumber;// num mClientNumber, fClientNumber
string mClientName, fClientName;// string mClientName, fClientName
bool atLeastOneFileNotAtEnd = true;
bool inFile1Written = false;
bool inFile2Written = false;
cout<<"File merge processing starting";

inFile1.open("MaleClients.rtf");
inFile2.open("FemaleClients.rtf");
outFile1.open ("MergedClients.rtf");
  
inFile1 >> mClientNumber; //Input
inFile1 >> mClientName;
inFile2 >> fClientNumber;
inFile2 >> fClientName;
  
while ( atLeastOneFileNotAtEnd == true ){//while loop
if(inFile1.eof()){
if (inFile2Written == false){
outFile1 << fClientNumber <<" "<<fClientName<<"\n";
inFile2Written = true;
}
}
else if(inFile2.eof()){
if (inFile1Written == false){
outFile1 << mClientNumber <<" "<<mClientName<<"\n";
inFile1Written = true;
}   
}
else if (mClientNumber < fClientNumber){
outFile1 << mClientNumber <<" "<<mClientName<<"\n";
inFile1Written = true;
}
else{
outFile1 << fClientNumber <<" "<<fClientName<<"\n";
inFile2Written = true;
}
  
if ((!inFile1.eof()) && (inFile1Written == true)){
inFile1 >> mClientNumber;
inFile1 >> mClientName;
inFile1Written = false;
}

if ((!inFile2.eof()) && (inFile2Written == true)){
inFile2 >> fClientNumber;
inFile2 >> fClientName;
inFile2Written = false;
}

if ((inFile1.eof()) && (inFile2.eof())){
atLeastOneFileNotAtEnd = false;
}

}

inFile1.close(); //close
inFile2.close();
outFile1.close();

cout<<"\nMerging Complete";
return 0;
}

MaleClients.rtf

1 Harry

FemaleClients.rtf
3 Olivia

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The assignment below has three pseudocodes below I need to fix the debug exercises in it....
The assignment below has three pseudocodes below I need to fix the debug exercises in it. Please help. Thanks. Highlight or mark in bold the corrections. Thanks! //DEBUG06-01 // A high school is holding a recycling competition, // and this program allows a user to enter a student's // year in school (1 through 4) and number of cans collected // for recycling. Data is entered continuously until the user // enters 9 for the year. // After headings, output...
Please check this code and see if this will work? Lab 1 – Print Labels Pendant...
Please check this code and see if this will work? Lab 1 – Print Labels Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author’s name, the title of the work, and a volume number in the form Volume 9 of 9. For example, a set of three volumes requires three labels: Volume 1 of 3, Volume 2 of 3, and Volume 3 of 3. Design an application that reads records...
debug the following 1) // The main program calls a method that // prompts for and...
debug the following 1) // The main program calls a method that // prompts for and returns a name start Declarations string usersName name = askUserForName() output "Your name is ", usersName stop string askUserForName() Declarations string name output "Please type your name " input usersName return 2) // The main program passes a user’s entry to // a method that displays a multiplication table // using the entered value. The table includes the // value multiplied by every factor...
C++ See the provided specification files. Complete the implementation for each as a separate file. void...
C++ See the provided specification files. Complete the implementation for each as a separate file. void seen(std::string); If there is already a Word object in the Words list, then the number of occurrences for this word is incremented. If there is no Word object for this word already, create a new word object with occurrence =1, and insert this object into the list of Word objects. std::string getNextWord(); Returns the next word of the list and sets the currentItem pointer...
The ability to read through Java™ code and predict the results, given specific inputs, is an...
The ability to read through Java™ code and predict the results, given specific inputs, is an extremely useful skill. For this assignment, you will be analyzing the Java™ code in the linked zip file, and predicting the results given specific input. Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document: What is the output of the program as it is written? What would the output of the program be if you...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int...
Write a C++ Program Consider the following incomplete C++ program: #include <iostream> using namespace std; int main() {    …. } Rewrite the program include the following statements. Include the header file fstream, string, and iomanip in this program. Declare inFile to be an ifstream variable and outFile to be an ofstream variable. The program will read data from the file inData.txt and write output to the file outData.txt. Include statements to open both of these files, associate inFile with...
Please answer the following C question: There is a documented prototype for a function called get_a_line...
Please answer the following C question: There is a documented prototype for a function called get_a_line in the code below. Write a definition for get_a_line—the only function called from that definition should be fgetc. #include <stdio.h> #include <string.h> #define BUFFER_ARRAY_SIZE 10 int get_a_line(char *s, int size, FILE *stream); // Does what fgets does, using repeated calls to fgetc, but // provides a more useful return value than fgets does. // // REQUIRES // size > 1. // s points to...
can someone edit my c++ code where it will output to a file. I am currently...
can someone edit my c++ code where it will output to a file. I am currently using xcode. #include <iostream> #include <cctype> #include <cstring> #include <fstream> using namespace std; bool inputNum(int [],int&,istream&); void multiply(int[],int,int[],int,int[],int&); void print(int[],int,int,int); int main() {ifstream input; int num1[35],num2[35],len1,len2,num3[60],len3=10,i; input.open("multiplyV2.txt"); //open file if(input.fail()) //is it ok? { cout<<"file did not open please check it\n"; system("pause"); return 1; }    while(inputNum(num1,len1,input)) {inputNum(num2,len2,input); multiply(num1,len1,num2,len2,num3,len3); print(num1,len1,len3,1); print(num2,len2,len3,2); for(i=0;i<len3;i++) cout<<"-"; cout<<endl; print(num3,len3,len3,1); //cout<<len1<<" "<<len2<<" "<<len3<<endl; cout<<endl;    } system("pause"); } void...
is there anything wrong with the solution. the question are from java course Write a main...
is there anything wrong with the solution. the question are from java course Write a main method that will request the user to enter Strings using a JOptionPane input dialog. The method should continue accepting strings until the user types “STOP”.       Then, using a JOptionPane message dialog, tell the user how many of the strings begin and end with a digit. Answer: import javax.swing.*; public class IsAllLetters {     public static void main(String[] args) {         String input;         int count =...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT