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 in.Least number of planes that landed on any one day and which month it occurred in.
#include
#include
// the number of months
const int count =12;
struct MonthInfo
{
int total_L; // planes landed
int total_D; // planes departed
int max_L; // highest number of planes
int min_L; // least number of planes
};
// input function
void inputInfo(MonthInfo& info)
{
using namespace std;
cout << "Enter total number of planes landed: ";
cin >> info.total_L;
cout << "Enter total number of planes departed: ";
cin >> info.total_D;
cout << "Enter greatest number of planes landed in a day: ";
cin >> info.max_L;
cout << "Enter least number of planes landed in a day: ";
cin >> info.min_L;
}
int main()
{
using namespace std;
MonthInfo year[count];
// collect the information for each month
for (int i =0; i < count; ++i)
{
cout << "Enter information for Month "<< i +1<<":
";
inputInfo(year[i]);
}
int total_L_Year =0;
int total_D_Year =0;
int max_L = year[0].max_L;
int min_L = year[0].min_L;
int max_L_Month =1;
int min_L_Month =1;
// calcilating statistics of the entire year
for (int i =0; i < count; ++i)
{
total_L_Year += year[i].total_L;
total_D_Year += year[i].total_D;
// month with moat number of plane landed ina day
if (year[i].max_L > max_L)
{
max_L = year[i].max_L;
max_L_Month = i +1;
}
// month with least number of plane landed ina day
if (year[i].min_L < min_L)
{
min_L = year[i].min_L;
min_L_Month = i +1;
}
}
// calculating the number of planes landed and departed monthly
double avg_Monthly_L = static_cast(total_L_Year)/ count;
double avg_Monthly_D = static_cast(total_D_Year)/ count;
// displaying the result
cout <<"
Average monthly number of landing planes: "<< avg_Monthly_L <<"
";
cout << "Average monthly number of departing planes: "<< avg_Monthly_D <<"
";
cout << "Total number of landing planes for the year: "<< total_L_Year <<"
";
cout << "Total number of departing planes for the year: "<< total_D_Year <<"
";
cout << "Greatest number of planes landed on a day: "<< max_L <<"(Month "<< max_L_Month <<")
";
cout << "Least number of planes landed on a day: "<< min_L <<"(Month "<< min_L_Month <<")
";
return 0;
}
i feel like the namespace location needs to be changed. And my const int count =12; variable. I'm 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!