#include <iostream>
using namespace std;
struct Mytime
{
int hours;
int mins;
};
int timecmp( Mytime t1, Mytime t2 ) // compares two Mytime values
{
if (t1.hours == t2.hours)
{
if (t1.mins == t2.mins)
{
return 0; // returns 0 if times are same
}
else // mins not same
{
if (t1 mins > t2 mins)
{
return 1; // returns >0 if first is later than second
}
else
{
return -1; // returns <0 if first is before second
}
}
}
else // hours not same
{
if (t1.hours > t2.hours)
{
return 1;
}
else
{
return -1;
}
}
}
int setTime(Mytime& t, int h, int m );
{
// if valid time sets hh and mm to h and m
// and returns 0
// if invalid returns integer > 0 as error code
// error code +1 = underflow hours
// error code +2 = overflow hours
// error code +4 = underflow mins
// error code +8 = overflow mins
t.hours = h;
t.mins = m;
return 0;
}
void display1Time(Mytime t);
{
cout << "00:00";
}
void elapsed(Mytime t1, Mytime t2, Mytime& duration);
{
setTime(duration,0,0);
}
int main()
{
Mytime now;
Mytime then;
Mytime howlong;
int h,m;
do
{
cout << "Enter start hh mm : ";
cin >> h >> m ;
} while (setTime(now,h,m));
do
{
cout << "Enter finish hh mm : ";
cin >> h >> m ;
} while (setTime(then,h,m));
elapsed(now,then,howlong);
cout << "Time elapsed from ";
display1Time(now);
cout << " until ";
display1Time(then);
cout << " is ";
display1Time(howlong);
cout << endl;
return ( 0 );
}
Dear All
Following functions are incomplete:
int setTime............
void displayTime........
void elapsetTime.......
I would be very happy if you could complete them with comments
I am confused again
regards