Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct airStats {
- int Landed;
- int Departed;
- int greatestLanded;
- int leastLanded;
- };
- int main(){
- const int size = 12;
- airStats planes[size];
- int index;
- cout << "Please enter the statistics when prompted.\n";
- cout << endl;
- for (index = 0; index < size; index++)
- {
- cout << "Total number of planes landed in month #" << (index + 1);
- cout << ": ";
- cin >> planes[index].Landed;
- cout << "Total number of planes departed in month #" << (index + 1);
- cout << ": ";
- cin >> planes[index].Departed;
- cout << "Greatest number of planes that landed in a day in month #" << (index + 1);
- cout << ": ";
- cin >> planes[index].greatestLanded;
- cout << "Least number of planes that landed in a day in month #" << (index + 1);
- cout << ": ";
- cin >> planes[index].leastLanded;
- cout << endl;
- }
- int Lsum = 0;
- for(int index = 0; index < size; index++)
- {
- Lsum = Lsum + planes[index].Landed;
- }
- cout << "The total number of planes that landed this year is " << Lsum << endl;
- int Dsum = 0;
- for(int index = 0; index < size; index++)
- {
- Dsum = Dsum + planes[index].Departed;
- }
- cout << "The total number of planes that departed this year is " << Dsum << endl;
- int totalPlanes = Lsum + Dsum;
- cout << "The total number of planes that landed and departed this year is " << totalPlanes << endl;
- cout << endl;
- double Laverage = Lsum / size;
- double Daverage = Dsum / size;
- cout << "The average number of planes that landed each month is " << Laverage << endl;
- cout << "The average number of planes that departed each month is " << Daverage << endl;
- cout << endl;
- int highest;
- int lowest;
- highest = planes[index].greatestLanded;
- for (index = 0; index < size; index++)
- {
- if (planes[index].greatestLanded > highest)
- highest = planes[index].greatestLanded;
- }
- cout << "The greatest number of planes that landed in a single day this year is " << highest << endl;
- lowest = planes[index].leastLanded;
- for (index = 0; index < size; index++)
- {
- if (planes[index].leastLanded < lowest)
- lowest = planes[index].leastLanded;
- }
- cout << "The lowest number of planes that landed in a single day this year is " << lowest << endl;
- cout << endl;
- for(index = 0; index < size; index++)
- {
- if(planes[index].greatestLanded == highest){
- cout << "The month that had the day with the most landed planes is month #" << index + 1 << endl;
- break;
- }
- }
- for(index = 0; index < size; index++)
- {
- if(planes[index].leastLanded == lowest){
- cout << "The month that had the day with the least landed planes is month #" << index + 1 << endl;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement