Advertisement
ruslanapetrova

Untitled

Oct 2nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. using namespace std;
  5. int main (){
  6. double examHour,minuteExam,hourofArrival,minuteofArrival;
  7. cin >> examHour>>minuteExam>>hourofArrival>>minuteofArrival;
  8.  
  9. int examTime = (examHour *60) + minuteExam;
  10. int arrivalTime = ( hourofArrival * 60) + minuteofArrival;
  11. int marginTime = arrivalTime - examTime;
  12. int marginSecond = examTime - arrivalTime;
  13.  
  14.  
  15. if(marginTime <= 59 && marginTime > 0)
  16. {
  17. cout << "Late " << marginTime << " minutes after the start"<<endl;
  18.  
  19. }
  20. else if( marginSecond == 0 ){
  21. cout <<"On time " << endl;
  22.  
  23. }else if (marginTime >=60 )
  24. {
  25. int hour = marginTime / 60;
  26. int minutes = marginTime % 60;
  27.  
  28. cout << "Late "<< hour << ":"<< minutes<< "hours after the start"<<endl;
  29.  
  30. }else if(marginSecond <= 30 && marginSecond > 0 ){
  31. cout <<"On time "<< marginSecond << "minutes before the start" <<endl;
  32.  
  33. }else if(marginSecond > 30 && marginSecond < 60 ){
  34. cout <<"Early "<< marginSecond << "minutes before the start"<<endl;
  35.  
  36. }else if (marginSecond >= 60 )
  37. {
  38. int hour = marginSecond /60;
  39. int minutes =marginSecond % 60;
  40. cout << "Early " <<marginSecond<< "hours before the start."<<endl;
  41.  
  42.  
  43.  
  44. }else if (marginSecond >= 60){
  45. int hour = marginSecond /60;
  46. int minutes =marginSecond % 60;
  47. cout << "Early " <<hour<<":"<< minutes<< "hours before the start."<<endl;
  48. }
  49.  
  50.  
  51.  
  52. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement