Question: Write a program that does the following: Utilizes each structure to store the following information for each month of the year: Total number of planes
Write a program that does the following:
Utilizes each structure to store the following information for each month of the year:
Total number of planes that landedTotal number of planes that departedGreatest number of planes that landed in a given day that monthLeast number of planes that landed in a given day that month
Store the twelve structures one structure for each month of the year in an array, which is intended to store 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 following:
Average monthly number of landing planesAverage monthly number of departing planesTotal number of landing planes for the yearTotal number of departing planes for the yearGreatest number of planes that landed on any one day and which month it occurred inLeast number of planes that landed on any one day and which month it occurred in
#include
#include
the number of months
const int count ;
struct MonthInfo
int totalL; planes landed
int totalD; planes departed
int maxL; highest number of planes
int minL; least number of planes
;
input function
void inputInfoMonthInfo& info
using namespace std;
cout "Enter total number of planes landed: ;
cin info.totalL;
cout "Enter total number of planes departed: ;
cin info.totalD;
cout "Enter greatest number of planes landed in a day: ;
cin info.maxL;
cout "Enter least number of planes landed in a day: ;
cin info.minL;
int main
using namespace std;
MonthInfo yearcount;
collect the information for each month
for int i ; i count; i
cout "Enter information for Month i :
;
inputInfoyeari;
int totalLYear ;
int totalDYear ;
int maxL yearmaxL;
int minL yearminL;
int maxLMonth ;
int minLMonth ;
calcilating statistics of the entire year
for int i ; i count; i
totalLYear yearitotalL;
totalDYear yearitotalD;
month with moat number of plane landed ina day
if yearimaxL maxL
maxL yearimaxL;
maxLMonth i ;
month with least number of plane landed ina day
if yeariminL minL
minL yeariminL;
minLMonth i ;
calculating the number of planes landed and departed monthly
double avgMonthlyL staticcasttotalLYear count;
double avgMonthlyD staticcasttotalDYear count;
displaying the result
cout
Average monthly number of landing planes: avgMonthlyL
;
cout "Average monthly number of departing planes: avgMonthlyD
;
cout "Total number of landing planes for the year: totalLYear
;
cout "Total number of departing planes for the year: totalDYear
;
cout "Greatest number of planes landed on a day: maxL Month maxLMonth
;
cout "Least number of planes landed on a day: minL Month minLMonth
;
return ;
i feel like the namespace location needs to be changed. And my const int count ; variable. Im not getting that correctly and need help to fix this issue. Thank you.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
