Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- int main (){
- double examHour,minuteExam,hourofArrival,minuteofArrival;
- cin >> examHour>>minuteExam>>hourofArrival>>minuteofArrival;
- int examTime = (examHour *60) + minuteExam;
- int arrivalTime = ( hourofArrival * 60) + minuteofArrival;
- int marginTime = arrivalTime - examTime;
- int marginSecond = examTime - arrivalTime;
- if(marginTime <= 59 && marginTime > 0)
- {
- cout << "Late " << marginTime << " minutes after the start"<<endl;
- }
- else if( marginSecond == 0 ){
- cout <<"On time " << endl;
- }else if (marginTime >=60 )
- {
- int hour = marginTime / 60;
- int minutes = marginTime % 60;
- cout << "Late "<< hour << ":"<< minutes<< "hours after the start"<<endl;
- }else if(marginSecond <= 30 && marginSecond > 0 ){
- cout <<"On time "<< marginSecond << "minutes before the start" <<endl;
- }else if(marginSecond > 30 && marginSecond < 60 ){
- cout <<"Early "<< marginSecond << "minutes before the start"<<endl;
- }else if (marginSecond >= 60 )
- {
- int hour = marginSecond /60;
- int minutes =marginSecond % 60;
- cout << "Early " <<marginSecond<< "hours before the start."<<endl;
- }else if (marginSecond >= 60){
- int hour = marginSecond /60;
- int minutes =marginSecond % 60;
- cout << "Early " <<hour<<":"<< minutes<< "hours before the start."<<endl;
- }
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement