Hello people...I'm interested in changing this program so that the user is ask to enter 10 login times (using a loop of 1 - 10) then print out the time difference between the first login and the last login...I made several attempts at it but all in vain...I'm just wondering if it is possible at all...Here is what I started with...Thanks
#include "time.h" // Main.cpp file
int main()
{
Time begin;
Time end;
Time check_in;
int h, m, s;
begin.set (12,0, 0);
end.set (18, 0, 0);
cout << " enter hour, min, sec\n ";
cin >>h>>m>>s;
check_in.set (h, m, s);
cout << " The time you checked in ";
check_in.print ();
if (check_in.Equal(begin))
cout << "You are right on time. Lets go to lunch !! ";
h = 0;
m = 0;
s = 0;
if(check_in.LessThan(begin))
{
while(!begin.Equal(check_in))
{
check_in.increment();
s++;
if (s == 60)
{
m++;
s = 0;
if (m == 60)
{
h++;
m = 0;
}
if (h == 24)
h = 0;
}
}
cout << " Good Morning you are early. You have to wait "<<h<<":"<<m<<":"<<s<< " for Lunch !! ";
}
if (check_in.Equal(end))
cout << "You are right on time. Lets have Dinner !! ";
h = 0;
m = 0;
s = 0;
if(check_in.GreaterThan(begin))
{
while(!end.Equal(check_in))
{
check_in.increment();
s++;
if (s == 60)
{
m++;
s = 0;
if (m == 60)
{
h++;
m = 0;
}
if (h == 24)
h = 0;
}
}
cout << " Good Afternoon you are late. You have to wait "<<h<<":"<<m<<":"<<s<< " for Dinner !! ";
return 0;
}
}
that' s a good possibility...but which loop would work with the array...I tried the do, while and for loops but every time it just loop twice and then stop...
Thanks a lot...I think I got it now...then all whats left for me to do is to get the difference from array [0] and array [9] computing in secs, mins, and hours....
so people...this is what i got finished...but i'm still having problems getting it to print out what I need...it prints the first output correct but the second one is only in seconds...also I'm trying to make it print the first login time...the last login time...and then the difference of the first and last...ALSO...I have to be able to print out the earliest of the 9 logins plus the latest of the 9 logins then get the difference from that....this is what I have...some help please...
If you do not need to use a class consider the following:
for(i=0;<10 loops;inci)
{
<<enter a time
>> time
array[i] = time
}
timediff=array[9]-array[0]
The array' loop' should have a size of 10. In your code the for loop will terminate when i=8.
Consider using a double type for decimal hours rather than h,m,s.
Write a function which will convert h,m,s to decimal hours and visa versa.