Advertisement
JOHNYTHEWINNER

Just on time

Jan 27th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     int examinehour;
  12.     int examineminutes;
  13.     int arrivinghour;
  14.     int arrivingminutes;
  15.     cin >> examinehour;
  16.     cin >> examineminutes;
  17.     cin >> arrivinghour;
  18.     cin >> arrivingminutes;
  19.     int examinetime = (examinehour * 60) + examineminutes;
  20.     int arrivingtime = (arrivinghour * 60) + arrivingminutes;
  21.     if (arrivingtime > examinetime)
  22.     {
  23.         cout << "Late";
  24.     }
  25.     else if ((arrivingtime >= (examinetime - 30)) && (arrivingtime <= examinetime))
  26.     {
  27.         cout << "On time";
  28.     }
  29.     else if (arrivingtime < (examinetime - 30))
  30.     {
  31.         cout << "Early";
  32.     }
  33.     if (abs(arrivingtime - examinetime) >= 1)
  34.     {
  35.         if ((examinetime - arrivingtime) < 60 && (examinetime - arrivingtime) > 0)
  36.         {
  37.             int minutes = (examinetime - arrivingtime);
  38.             cout << " " << minutes << " minutes before the start" << endl;
  39.         }
  40.         if ((arrivingtime - examinetime) < 60 && (arrivingtime - examinetime) > 0)
  41.         {
  42.             int minutes = (arrivingtime - examinetime);
  43.             cout << " " << minutes << " minutes after the start" << endl;
  44.         }
  45.         if ((examinetime - arrivingtime) >= 60)
  46.         {
  47.             double hours = ((examinetime - arrivingtime) / 60);
  48.             if (hours > 23)
  49.             {
  50.                 hours -= 24;
  51.             }
  52.             int minutes = ((examinetime - arrivingtime) - floor(hours) * 60);
  53.             if (minutes < 10)
  54.             {
  55.                 cout << " " << fixed << setprecision(0) << hours << ":0" << minutes << "hours before the start" << endl;
  56.             }
  57.             else
  58.             {
  59.                 cout << " " << fixed << setprecision(0) << hours << ":" << minutes << " hours before the start" << endl;
  60.             }
  61.         }
  62.         if ((arrivingtime - examinetime) >= 60)
  63.         {
  64.             double hours = ((arrivingtime - examinetime) / 60);
  65.             if (hours > 23)
  66.             {
  67.                 hours -= 24;
  68.             }
  69.             int minutes = ((arrivingtime - examinetime) - floor(hours) * 60);
  70.             if (minutes < 10)
  71.             {
  72.                 cout << " " << fixed << setprecision(0) << hours << ":0" << minutes << "hours after the start" << endl;
  73.             }
  74.             else
  75.             {
  76.                 cout << " " << fixed << setprecision(0) << hours << ":" << minutes << " hours after the start" << endl;
  77.             }
  78.         }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.     }
  85.  
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement