I have an issue with a section of code that will not work correctly. The first instance work fine but everything after is junk data.
int arrivaltime = 0;
int servicetime = 0;
int waittime = 0;
// This section shows the bank wait time for the different branch and tellers
std::ifstream in("bankSMALL.txt",std::ios::in |std::ios::binary);
cout<< "Branch Teller ID Arrival Time Service Time Wait time/sec" <<endl;
if(!in)
{
std::cout<<"Could not open file"<<std::endl;
}
//this is where we are reading in the information into our array
while( in)
{
in >> branchnumber >> tellern1 >> tellern2 >> ahr1 >> ahr2 >> amin1 >>amin2 >> asec1 >> asec2
>> shr1 >>shr2 >> smin1 >> smin2 >> ssec1 >> ssec2;
cout << " " << branchnumber << " ";
cout <<" "<< tellern1 << tellern2;
cout <<" " << ahr1 << ahr2 << ":" << amin1 << amin2 << ":"<< asec1 << asec2;
cout <<" " << shr1 << shr2 << ":" << smin1 << smin2 << ":"<< ssec1 << ssec2;
// calculate the arrival time, service time and wait time in sec
arrivaltime = ((ahr1 * 10) + ahr2) * SEC_PER_HR + ((amin1 + amin2) * sec) + (asec1 + asec2);
servicetime = ((shr1 * 10) + shr2) * SEC_PER_HR + ((smin1 + smin2) * sec) + (ssec1 + ssec2);
waittime = servicetime - arrivaltime;
cout << " " << waittime <<endl;
loopCount++;
}
I have to convert hrs, min, sec into just sec for both the arrival time and service time and out put the wait time from the two. My data set is as such:
arrival / service / wait (should be)
14:12:51 / 14:16:59 / 248
09:05:37 / 09:07:48 / 131
10:15:02 / 10:29:29 / 867
I set waittime = 0 in the begining of the loop. Can someone help me