i'm having a trouble getting this right ..
Write a program to calculate parking fee for customers who park their vehicles in a parking lot when the following information is given:
The time the vehicle entered the lot (in 24-hour format, without a colon, such as 1645)
The time the vehicle left the lot, also in 24-hour format without a colon.
To calculate the actual time spent in the parking lot, you may use this algorithm (it's not the only way to do it):
Compare the minute portion of the leaving and entering time. If the first one is smaller than the second,
Add 60 to the minute portion of the leaving time.
Subtract 1 from the hour portion of the leaving time.
Subtract the hour portions.
Subtract the minute portions
was try using the split hour to calculate the hourly and minutes but it didnot come out right ..
cout << "Time entered? ";
cin >> enter;
cout << "Time departed? ";
cin >> exit;
minutesEnter = enter % 60;
hoursEnter = enter / 60;
minutesExit = exit + 60;
hoursExit = exit - 1;
cout << fixed;
cout.precision(2);
cout << setfill('0');
cout << "Time in: " << hoursEnter << ":" << setw(2) << minutesEnter << endl;
cout << "Time out: " << hoursExit << ":" << setw(2) << minutesExit << endl;
<< moderator edit: added [code][/code] tags >>
i'm sort of new to this .. please help me out ..
thank you =)