In: Computer Science
****user comments: PLEASE READ INSTRUCTIONS THOROUGHLY AND KEEP THE
STRUCTURE OF THE PROGRAM. JUST ADD THE ADDITIVES NEEDED
IN ORDER TO SUFFICE THE PROGRAM. PLEASE MAKE SURE IT IS IN C++ AND
WORKS! THANK YOU!****
Write a program that uses a structure to store the following information for a particular month at the local airport:
Total number of planes that landed
Total number of planes that departed
Greatest number of planes that landed in a given day that
month
Least number of planes that landed in a given day that month
The program should have an array of twelve structures to hold
travel information for the entire year.
The program should prompt the user to enter data for each
month.
Once all data is entered, the program should calculate and output
the aver- age monthly number of landing planes,
the average monthly number of depart- ing planes, the total number
of landing and departing planes for the year,
and the greatest and least number of planes that landed on any one
day (and which month it occurred in).
PROGRAM NEEDED EDITING:
// This program uses a structure to hold data about an airport.
// PLACE YOUR NAME HERE
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct airport // defines the structure airport
{
int landed; // planes landed in a month
int departed; // planes departured in a month
int mostLanded; // greatest number of planes landed in one day in
the month
int leastLanded; // least number of planes landed in one day in the
month
};
const int MAXMONTH = 12;
int main()
{
airport planes[MAXMONTH];
int pos; // loop counter
int totalLandings = 0; // Total landings in the year
int totalDeparted = 0; // Total departures in a year
int mostLandings = 0; // Day of most landings
int leastLandings = 99999; // Day of least landings
string monthMost; // Month that had most single day landings
string monthLeast; // Month that had least single day
landings
string month;
//add for loop to count through array
//use a switch to determine month
cout << "Please enter the number of planes that landed in
" << month << ": ";
cin >> planes[pos].landed;
cout << "Please enter the number of planes that departed
in " << month << ":";
cin >> //add code here
cout << "Please enter the greatest number of planes that
landed on a single day in "
<< month << ": ";
cin >> //add code here
cout << "Please enter the least number of planes that
landed on a single day in "
<< month << ": ";
cin >> //add code here
totalLandings = //add code here
totalDeparted = //add code here
if (mostLandings < planes[pos].mostLanded)
{
mostLandings = //add code here
monthMost = month;
}
if (leastLandings > planes[pos].leastLanded)
{
leastLandings = //add code here
monthLeast = month;
}
}
cout << setprecision(2) << fixed << showpoint;
cout << "The average monthly landings for the year is
"
<< (float)totalLandings/MAXMONTH << endl;
cout << "The average monthly departures for the year is
"
<< (float)totalDeparted/MAXMONTH << endl;
cout << "The total landings for the year is " <<
totalLandings << endl;
cout << "The total departures for the year is " <<
totalDeparted << endl;
cout << "The greatest number of planes that landed in a
single day is "
<< mostLandings << " which occured in the month of "
<< monthMost << endl;
cout << "The least number of planes that landed in a
single day is "
<< leastLandings << " which occured in the month of "
<< monthLeast << endl;
return 0;
}
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct airport // defines the structure airport
{
int landed; // planes landed in a month
int departed; // planes departured in a month
int mostLanded; // greatest number of planes landed in
one day in the month
int leastLanded; // least number of planes landed in
one day in the month
};
const int MAXMONTH = 12;
int main()
{
airport planes[MAXMONTH];
int pos; // loop counter
int totalLandings = 0; // Total landings in the
year
int totalDeparted = 0; // Total departures in a
year
int mostLandings = 0; // Day of most landings
int leastLandings = 99999; // Day of least
landings
string monthMost; // Month that had most single day
landings
string monthLeast; // Month that had least single day
landings
string month;
//add for loop to count through array
//use a switch to determine month
for(pos=0;pos<MAXMONTH;pos++)
{
//switch to determine month
switch(pos)
{
case 0:
month="January";
break;
case 1:
month="February";
break;
case 2:
month="March";
break;
case 3:
month="April";
break;
case 4:
month="May";
break;
case 5:
month="June";
break;
case 6:
month="July";
break;
case 7:
month="August";
break;
case 8:
month="September";
break;
case 9:
month="October";
break;
case 10:
month="November";
break;
case 11:
month="December";
break;
}
cout << "Please enter the
number of planes that landed in " << month << ":
";
cin >>
planes[pos].landed;
cout << "Please enter the
number of planes that departed in " << month <<
":";
//take input
cin >>
planes[pos].departed;//add code here
cout << "Please enter the
greatest number of planes that landed on a single day in "
<< month << ": ";
//take mostLanded input
cin >>
planes[pos].mostLanded;//add code here
cout << "Please enter the
least number of planes that landed on a single day in "
<< month << ": ";
//take least landed
input
cin >>planes[pos].leastLanded
;//add code here
//increment totalLandings and
totalDeparted
totalLandings
=totalLandings+planes[pos].landed; //add code here
totalDeparted =
totalDeparted+planes[pos].departed;//add code here
//update mostLandings
if (mostLandings <
planes[pos].mostLanded)
{
mostLandings =
planes[pos].mostLanded;//add code here
monthMost =
month;
}
if (leastLandings >
planes[pos].leastLanded)
{
leastLandings =
planes[pos].leastLanded;//add code here
monthLeast =
month;
}
}
cout << setprecision(2) << fixed <<
showpoint;
cout << "The average monthly landings for the
year is "
<< (float)totalLandings/MAXMONTH <<
endl;
cout << "The average monthly departures for the
year is "
<< (float)totalDeparted/MAXMONTH <<
endl;
cout << "The total landings for the year is "
<< totalLandings << endl;
cout << "The total departures for the year is "
<< totalDeparted << endl;
cout << "The greatest number of planes that
landed in a single day is "
<< mostLandings << " which occured in the
month of " << monthMost << endl;
cout << "The least number of planes that landed
in a single day is "
<< leastLandings << " which occured in the
month of " << monthLeast << endl;
return 0;
}