How can I use an array of structs to calculate and display data about departing and landing planes?

Discussion in 'C++' started by Sean Van Zant, Nov 29, 2018.

  1. Sean Van Zant

    Sean Van Zant New Member

    Joined:
    Nov 26, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    I am coding a program that uses an array of structures with a menu.

    I need to calculate and output the average number of landing planes, the average number of departing planes, the total number of landing and departing planes for the year, and the greatest and least number of planes that landed in one day (and which month it occurred in).
    Code:
    #include <iostream>
    
    using namespace std;
    
    struct MonthlyInfo {
        int numLand;
        int numDepart;
        int maxNumLand;
        int minNumLand;
    };
    
    MthlyInfo yearinfo[12];
    
    int main()
    {
        int mthlyPlnLand;
        int mthlyPlnDep;
        int grtNumPlnLand;
        int lowNumPlnLand;
    
        for (index = 0; index < yearinfo[index]; index++) {
            cout << "How many planes have landed this month? " << endl;
            cin >> yearinfo[index].mthlyPlnLand;
    
            cout << "How many planes have departed this month? " << endl;
            cin >> mthlyPlnDep[index].mthlyPlnDept;
        }
    
        cout << "The greatest number of plans that landed in a given day  that month are: "
    
        return 0;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice