Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Wte a prr that ues a structux to sto thfn informa for a particuar morth at the l

ID: 3713323 • Letter: W

Question

Wte a prr that ues a structux to sto thfn informa for a particuar morth at the local aport Tol number oplanes that landed Total umbero planes that dpaed Last nbplanes that larxled in a givn day that mont The proprn should bave an arra of twelv structures t hold travel informaion forthe cnti yeaOrce all dta is entered, thu prgsould calcure and ourput the averape mcnthly number ot landing panes, the avurag onthly number of paanes, the total numberland depating planes for the year, ad the greatest and kest number ot plnes that laidany odwch onth it veurred . Your program should open a text fle and read in the datz fior the rwelve months. Copy the data at the end of the lab manual into a text fil. Usc ths d:ta to vabdare your pritthe sampke ru be he-verage nonthly landings for the year is 38194-98 he aveage nonthly departures for the year i 8758.92 he total landings for the year is 458329 he total departures for the year is 189187 uly had the greatest nunber of planes that landed in a single day: 2493 ebuary had the least nunber of planes that landed in a single day: 989 rocess returned ? (Bel) execution tine : 0.831 ress any key to continue 38945 1989 1200 1009 18915 1989 1800 309 34945 44989 1900 1112 28945 24989 1800 1900 24945 45.34 2341 1344 29999 28889 1098 1000 45725 5356 2493 1907 38945 54939 45900 45336 2008 1076 28798 27615 13D0 1001 35662 5426 1397 6575 36576 12B6 1007

Explanation / Answer

#include<stdio.h>
void main()
{
   struct trains_info
   {
    int planes_landed;
    int planes_departed;
    int max_no_planes;
    int least_no_planes;
};
struct train_info train_list[12];
int n,i;
printf("enter the 12 months trains data");
scanf("%d",&n);
for(i=0;i<12;i++)
{
    scanf("%d",&train_list[i].planes_landed);
    scanf("%d",&train_list[i].planes_departed);
    scanf("%d",&train_list[i].max_no_planes);
    scanf("%d",&train_list[i].least_no_planes);
}
float avg_planes_landed,avg_planes_departed;
int total_planes_landed=0,total_planes_departed=0,max_day=0,min_day=train_list[0].planes_departed;
int highest_landed_mnth,least_landed_mnth;
for(i=0;i<n;i++)
{
    total_planes_landed+=train_list[i].planes_landed;
    total_planes_departed+=train_list[i].planes_departed;
    if(max_day<train_list[i].planes_landed)
         {
          max_day=train_list[i].planes_landed;
          highest_landed_mnth=i;
         }

    if(min_day>train_list[i].planes_departed)
         {
         min_day=train_list[i].planes_departed;
         least_landed_mnth=i;
         }

}
avg_planes_landed=total_planes_landed/12;
avg_planes_departed=total_planes_departed/12;

printf("The average Monthly landings for the year is %f ",avg_planes_landed);
printf("The average Monthly departures for the year is %f ,avg_planes_departed);
printf("The total landings for the year is %d",total_planes_landed);
printf("The total departures for the year is %f",total_planes_departed);
char highest_mnth[15];
char least_mnth[15];
switch(highest_landed_mnth)
{
    case 0:
          highest_mnth="January";
          break;
    case 1:
          highest_mnth="Febraury";
          break;
    case 2:
          highest_mnth="March";
          break;
    case 3:
          highest_mnth="April";
          break;
    case 4:
          highest_mnth="May";
          break;
    case 5:
          highest_mnth="June";
          break;
    case 6:
          highest_mnth=July";
          break;
    case 7:
          highest_mnth="August";
          break;
    case 8:
          highest_mnth="September";
          break;
    case 9:
          highest_mnth="October";
          break;
    case 10;
          highest_mnth="November";
          break;
    case 11:
          highest_mnth="December";
          break;
}
   switch(least_landed_mnth)
{
    case 0:
          least_mnth="January";
          break;
    case 1:
          least_mnth="Febraury";
          break;
    case 2:
          least_mnth="March";
          break;
    case 3:
          least_mnth="April";
          break;
    case 4:
          least_mnth="May";
          break;
    case 5:
          least_mnth="June";
          break;
    case 6:
          least_mnth=July";
          break;
    case 7:
          least_mnth="August";
          break;
    case 8:
          least_mnth="September";
          break;
    case 9:
          least_mnth="October";
          break;
    case 10;
          least_mnth="November";
          break;
    case 11:
          least_mnth="December";
          break;
}
printf("%s had the greatest number of planes that landed in a single day :%d",highest_mnth,highest_landed_mnth);
printf("%s had the least number of planes that landed in a single day :%d",least_mnth,least_landed_mnth);

}