The Acme Travel Agency specializes in airline travel, and due to your quality as
ID: 441873 • Letter: T
Question
The Acme Travel Agency specializes in airline travel, and due to your quality assurance experience, you are assigned to analyze the quality of different flight plans. A flight plan consists of N connecting flights. After each flight except for the last one, there is a layover period in which the passenger must wait for the next flight. You have been tasked to calculate the destination time (without taking into account time zone changes), as well as the quality of the flight plan. If the total time that a passenger is flying as at least two times greater than the time in layover, a flight plan is considered to be efficient. Otherwise, a flight plan is considered to be inefficient. To calculate the destination time, add the total trip duration (the sum of all flight a layover durations) to the departure time, and calculate the corresponding time in a 24-hour clock format. Note that flight plans may last overnight, or may have a duration greater than a day. As an example, if a flight plan departed at 09:30 and lasted for 2000 minutes (thatExplanation / Answer
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int N;
int hours,minutes;
int flight,L;
int Ftotal=0,Ltotal=0;
int i;
scanf("%d",&N);
scanf("%d %d",&hours,&minutes);//hoursour minutesinute
for(i=0;i<N-1;i++){
scanf("%d %d",&flight,&L);
Ftotal+=flight;
Ltotal+=L;
}
scanf("%d",&flight);
Ftotal+=flight;
minutes+=(hours*60)+Ftotal+Ltotal;//convert to all minutesinute
hours=minutes/60;
hours%=24;
minutes%=60;
//print message
if(Ftotal>=2*Ltotal)
printf("The flight plan is efficient, and will conclude at d:d",hours,minutes);
else
printf("The flight plan is inefficient, and will conclude at d:d",hours,minutes);
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.