Question: How do I put these templates together to make a C++ code that will read two integers from numbers.txt? Template #1- #include CalculateDelayHeader.h int main()

How do I put these templates together to make a C++ code that will read two integers from "numbers.txt?"

Template #1-

#include "CalculateDelayHeader.h"

int main() { std::string filename="numbers.txt"; std::ifstream inFile; int delay=0; //open the file bool ok = openFile(filename, inFile); //if open successfully if (ok){ //while there are data sets while (ok){ //calculate delay delay =processFile(inFile); // display the calculated delay displayDelay(delay); //check if more data ok=checkFile(inFile);

}

} }

Template #2 -

#include "CalculateDelayHeader.h" //check if file is available

bool openFile( std::string filename, std::ifstream &inFile){ inFile.open(filename); if (inFile.fail()) return false; else return true;

} //display the delay void displayDelay(int delay){ std::cout

//divide tempDelay by 100 // add line here // if tempDelay equals 12, set it to 0 // add line here // multiply tempActual by 60 and add actual%100 // add line here //calculate difference between tempDelay and tempActual // add line here return diff;

} //read the data sets from the file int processFile(std::ifstream &inFile){ int actual, delay; inFile>>actual>>delay; std::cout

Template #3 -

#include #include #include #include using std::string; bool openFile(std::string filename, std::ifstream &inFile); int processFile(std::ifstream &inFile); bool checkFile(std::ifstream &inFile); void displayDelay(int delay);

How do I put these templates together to make a C++ code

numbers.txt - Notepad File Edit Format View Help |1145 1159 1140 1140 0455 0500 0344 0405 1230 0245

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!