Airport Activity Problem

Hello I am fairly new to C++ and I am having a small issue with this project. The problem that I am having lies in the last part of the MAIN FUNCTION where I need to display the "greatest" and "least" planes landed in a single day out of a whole year. I have the correct number for the landings and the departures but I am struggling on getting what month of the year these two values occurred in. Here is the specifications for this part of the assignment.

• Largest number of planes that landed in a single day (in the entire year) and the month in which it occurred
• Smallest number of planes that landed in a single day (in the entire year) and the month in which it occurred

If anyone could lend some assistance that would be great.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  #include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//data structure to store all the information from the user
struct Airport
{
	int totalLanded;
	int totalTookOff;
	int greatestLanded;
	int leastLanded;
};

//enumerated list of all the months of the year to let the displayMonth function display the correct month 
enum Month {January, Febuary, March, April, May, June, July, August, September, October, November, December};

//function prototype
void displayMonth(Month date);

int main()
{
	//starting variables values for the equation for the end result
	double totalLandedPerYear = 0.0;
	double totalDepartedPerYear = 0.0;
	double averageLanded = 0.0;
	double averageDeparted = 0.0;

	Airport *months;
	months = new Airport[12];
	Month flightMonth;

	//for loop to get the data from the user
	for (flightMonth = January; flightMonth <= December; flightMonth = static_cast<Month>(flightMonth + 1))
	{
		cout << "Please enter the number of planes that landed in "; 
		displayMonth(flightMonth);
		cout << ": ";
		cin >> months[flightMonth].totalLanded;
		cout << "Please enter the number of planes that departed in ";
		displayMonth(flightMonth);
		cout << ": ";
		cin >> months[flightMonth].totalTookOff;
		cout << "Please enter the greatest number of planes that landed on a single day in ";
		displayMonth(flightMonth);
		cout << ": ";
		cin >> months[flightMonth].greatestLanded;
		cout << "Please enter the least number of planes that landed on a single day in ";
		displayMonth(flightMonth);
		cout << ": ";
		cin >> months[flightMonth].leastLanded;
	}

	//for loop to add all the landings per month
	for (flightMonth = January; flightMonth <= December; flightMonth = static_cast<Month>(flightMonth + 1))
	{
		totalLandedPerYear += months[flightMonth].totalLanded;
	}

	//for loop to add all the departures per month
	for (flightMonth = January; flightMonth <= December; flightMonth = static_cast<Month>(flightMonth + 1))
	{
		totalDepartedPerYear += months[flightMonth].totalTookOff;
	}

	//equation to get the average landings per year
	averageLanded = totalLandedPerYear / 12;
	cout << "The average monthly landings for the year is " << averageLanded << endl;

	//equation to get the average departures per year
	averageDeparted = totalDepartedPerYear / 12;
	cout << "The average monthly departures for the year is " << averageDeparted << endl;

	cout << "The total landings for the year is " << totalLandedPerYear << endl;
	cout << "The total departures for the year is " << totalDepartedPerYear << endl;

	int greatestPlanes;
	int leastPlanes;

	//for loop to find the month with the most landings per year
	greatestPlanes = months[January].greatestLanded;
	for (flightMonth = January; flightMonth <= December; flightMonth = static_cast<Month>(flightMonth + 1))
	{
		if (months[flightMonth].greatestLanded > greatestPlanes)
		{
			greatestPlanes = months[flightMonth].greatestLanded;
		}
	}
	cout << "The greatest number of planes that landed in a single day is " << greatestPlanes;
	cout << " which occured in the month of " << endl;

	//for loop to find the month with the most departures per year
	leastPlanes = months[January].leastLanded;
	for (flightMonth = January; flightMonth <= December; flightMonth = static_cast<Month>(flightMonth + 1))
	{
		if (months[flightMonth].leastLanded < leastPlanes)
		{
			leastPlanes = months[flightMonth].leastLanded;
		}
	}
	cout << "The least number of planes that landed in a single day is " << leastPlanes;
	cout << " which occured in the month of " << endl;

	cin.get();
	cin.ignore();
	return 0;
}

//function to display the month for the user input phase of the program
void displayMonth(Month date)
{
	switch (date)
	{
	case January: cout << "January";
		break;
	case Febuary: cout << "Febuary";
		break;
	case March: cout << "March";
		break;
	case April: cout << "April";
		break;
	case May: cout << "May";
		break;
	case June: cout << "June";
		break;
	case July: cout << "July";
		break;
	case August: cout << "August";
		break;
	case September: cout << "September";
		break;
	case October: cout << "October";
		break;
	case November: cout << "November";
		break;
	case December: cout << "December";
		break;
	}
}
Hints:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iomanip>
#include <iostream>
#include <string>

//data structure to store all the information from the user
struct Airport
{
    int totalLanded;
    int totalTookOff;
    int greatestLanded;
    int leastLanded;
};

// enumerated list of all the months of the year to let the displayMonth
// function display the correct month
enum Month {January, Febuary, March,     April,   May,      June,
            July,    August,  September, October, November, December};

//function prototype
const char* displayMonth(Month date);

int main()
{
    Airport months[12] {};

    //for loop to get the data from the user
    for ( Month flightMonth = January;
          flightMonth <= December;
          flightMonth = static_cast<Month>(flightMonth + 1) )
    {
        std::cout << "Please enter the number of planes that landed in "
                  << displayMonth(flightMonth) << ": ";
        std::cin >> months[flightMonth].totalLanded;
        std::cout << "Please enter the number of planes that departed in "
                  << displayMonth(flightMonth) << ": ";
        std::cin >> months[flightMonth].totalTookOff;
        std::cout << "Please enter the greatest number of planes that landed "
                     "on a single day in " << displayMonth(flightMonth) << ": ";
        std::cin >> months[flightMonth].greatestLanded;
        std::cout << "Please enter the least number of planes that landed on "
                     "a single day in " << displayMonth(flightMonth) << ": ";
        std::cin >> months[flightMonth].leastLanded;
    }

    //for loop to add all the landings per month
    double totalLandedPerYear = 0.0;
    for ( Month flightMonth = January;
          flightMonth <= December;
          flightMonth = static_cast<Month>(flightMonth + 1) )
    {
        totalLandedPerYear += months[flightMonth].totalLanded;
    }

    //for loop to add all the departures per month
    double totalDepartedPerYear = 0.0;
    for ( Month flightMonth = January;
          flightMonth <= December;
          flightMonth = static_cast<Month>(flightMonth + 1) )
    {
        totalDepartedPerYear += months[flightMonth].totalTookOff;
    }

    //equation to get the average landings per year
    double averageLanded = totalLandedPerYear / 12;
    std::cout << "The average monthly landings for the year is "
              << averageLanded << '\n';

    //equation to get the average departures per year
    double averageDeparted = totalDepartedPerYear / 12;
    std::cout << "The average monthly departures for the year is "
              << averageDeparted << '\n';

    std::cout << "The total landings for the year is " << totalLandedPerYear << '\n';
    std::cout << "The total departures for the year is " << totalDepartedPerYear << '\n';

    //for loop to find the month with the most landings per year
    int greatestPlanes = months[January].greatestLanded;
    Month mostLanded = January;
    for ( Month flightMonth = January;
          flightMonth <= December;
          flightMonth = static_cast<Month>(flightMonth + 1) )
    {
        if (months[flightMonth].greatestLanded > greatestPlanes)
        {
            greatestPlanes = months[flightMonth].greatestLanded;
            mostLanded = flightMonth;
        }
    }
    std::cout << "The greatest number of planes that landed in a single day is "
              << greatestPlanes << " which occured in the month of " 
              << displayMonth(mostLanded) << '\n';

    //for loop to find the month with the most departures per year
    int leastPlanes = 9999; // you need a big number here
    Month leastArrivals = January;
    for ( Month flightMonth = January;
          flightMonth <= December;
          flightMonth = static_cast<Month>(flightMonth + 1) )
    {
        if (months[flightMonth].leastLanded < leastPlanes)
        {
            leastPlanes = months[flightMonth].leastLanded;
            leastArrivals = flightMonth;
        }
    }
    std::cout << "The least number of planes that landed in a single day is "
              << leastPlanes << " which occured in the month of "
              << displayMonth(leastArrivals) << '\n';

    std::cin.get();
    std::cin.ignore();
    return 0;
}

//function to display the month for the user input phase of the program
const char* displayMonth(Month date)
{
    switch (date)
    {
    case January:   return "January";
    case Febuary:   return "Febuary";
    case March:     return "March";
    case April:     return "April";
    case May:       return "May";
    case June:      return "June";
    case July:      return "July";
    case August:    return "August";
    case September: return "September";
    case October:   return "October";
    case November:  return "November";
    case December:  return "December";
    }
}

Thank you I got the program working, but I am still getting a warning from the compiler stating:

warning C4715: 'displayMonth' : not all control paths return a value.

Any suggestions?
Never Mind I figured it out. Thank you for all your help.
Topic archived. No new replies allowed.