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
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
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