Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Language C++ Givens: Key Program: OPmcopy key-fileMerge.run ./key-fileMerge.run Sample function: InFileValueCount.cpp NOTE: YOUR PROGRAM must behave EXACTLY LIKE key-fileMerge.run!! Description: Design and write a program
Language C++ Givens: Key Program: OPmcopy key-fileMerge.run ./key-fileMerge.run Sample function: InFileValueCount.cpp NOTE: YOUR PROGRAM must behave EXACTLY LIKE key-fileMerge.run!! Description: Design and write a program that merges the contents of two sorted input files containing integer values into a single sorted output file. Required Input/Output Formats: Input Prompt: Enter Name of Input File 1: Enter Name of Input File 2: Enter Name of Output File: Output labels/format: (x marks define field width) INPUT FILE1 'infilename1' : CONTAINS xxx VALUES INPUT FILE2 'infilename2' : CONTAINS xxx VALUES INPUT FILE1 'infilename1' : SUM OF VALUES = xxxxxx INPUT FILE2 'infilename2' : SUM OF VALUES = xxxxxx OUTPUT FILE 'outfilename' : CONTAINS xxx VALUES OUTPUT FILE 'outfilename' : SUM OF VALUES = xxxxxx ... DESIGN CONSTRAINTS: (1) Design and implement the following functions. // --------------------------------------------------------------- // Open specified input file. // --------------------------------------------------------------- void OpenInputFile(ifstream & inF, char inFileName[]); // --------------------------------------------------------------- // Return the number of values in input file (already open). // NOTE: The function must first REWIND the file before starting. // --------------------------------------------------------------- int InFileValueCount (istream &inF); // --------------------------------------------------------------- // Read a value from an OPEN input file; set success to FALSE if // value can not be read. // --------------------------------------------------------------- void ReadValue (istream &inF, int & num, bool & success); // --------------------------------------------------------------- // Write a value to output stream, eight(8) values per line. // Separate values by ONE SPACE. // --------------------------------------------------------------- void WriteValue (ostream & outF, int num); // --------------------------------------------------------------- // Return the sum of values in input file (already open). // NOTE: The function must first REWIND the file before starting. // --------------------------------------------------------------- int Sum (istream &inF); (2) DO NOT USE ARRAYS. EXAMPLES: Input file1: 1 2 3 6 10 13 Input file2: 1 4 5 6 10 12 14 Output file: 1 1 2 3 4 5 6 6 10 10 12 13 14 Input file1: 1 2 3 Input file2: Output file: 1 2 3 Input file1: Input file2: 1 2 3 Output file: 1 2 3 Input file1: 5 7 8 Input file2: Output file: 5 7 8 Input file1: (empty) Input file2: (empty) Output file: (empty) Input file1: missing OR Input file1: 2 3 Input file2: 1 2 3 Input file2: missing Output file: not created. Output file: not created. Message: FATAL ERROR: Unable to OPEN file 'file1' (file2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started