Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- using namespace std;
- #include <iomanip>
- #include <math.h>
- #include <cmath>
- int main()
- {
- int examinehour;
- int examineminutes;
- int arrivinghour;
- int arrivingminutes;
- cin >> examinehour;
- cin >> examineminutes;
- cin >> arrivinghour;
- cin >> arrivingminutes;
- int examinetime = (examinehour * 60) + examineminutes;
- int arrivingtime = (arrivinghour * 60) + arrivingminutes;
- if (arrivingtime > examinetime)
- {
- cout << "Late";
- }
- else if ((arrivingtime >= (examinetime - 30)) && (arrivingtime <= examinetime))
- {
- cout << "On time";
- }
- else if (arrivingtime < (examinetime - 30))
- {
- cout << "Early";
- }
- if (abs(arrivingtime - examinetime) >= 1)
- {
- if ((examinetime - arrivingtime) < 60 && (examinetime - arrivingtime) > 0)
- {
- int minutes = (examinetime - arrivingtime);
- cout << " " << minutes << " minutes before the start" << endl;
- }
- if ((arrivingtime - examinetime) < 60 && (arrivingtime - examinetime) > 0)
- {
- int minutes = (arrivingtime - examinetime);
- cout << " " << minutes << " minutes after the start" << endl;
- }
- if ((examinetime - arrivingtime) >= 60)
- {
- double hours = ((examinetime - arrivingtime) / 60);
- if (hours > 23)
- {
- hours -= 24;
- }
- int minutes = ((examinetime - arrivingtime) - floor(hours) * 60);
- if (minutes < 10)
- {
- cout << " " << fixed << setprecision(0) << hours << ":0" << minutes << "hours before the start" << endl;
- }
- else
- {
- cout << " " << fixed << setprecision(0) << hours << ":" << minutes << " hours before the start" << endl;
- }
- }
- if ((arrivingtime - examinetime) >= 60)
- {
- double hours = ((arrivingtime - examinetime) / 60);
- if (hours > 23)
- {
- hours -= 24;
- }
- int minutes = ((arrivingtime - examinetime) - floor(hours) * 60);
- if (minutes < 10)
- {
- cout << " " << fixed << setprecision(0) << hours << ":0" << minutes << "hours after the start" << endl;
- }
- else
- {
- cout << " " << fixed << setprecision(0) << hours << ":" << minutes << " hours after the start" << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement