#include #include #include //for class string using namespace std; int main() { string name[] = { "January", // 0 "February", // 1 "March", // 2 "April", // 3 "May", // 4 "June", // 5 "July", // 6 "August", // 7 "September", // 8 "October", // 9 "November", //10 "December" //11 }; int length[] { 31, // 0 January 28, // 1 February 31, // 2 March 30, // 3 April 31, // 4 May 30, // 5 June 31, // 6 July 31, // 7 August 30, // 8 September 31, // 9 October 30, //10 November 31 //11 December }; int n {size(name)}; //number of elements in array cout << "Please type a month: "; string monthname; cin >> monthname; //Input one word. if (!cin) { cerr << "Sorry, couldn't receive input.\n"; return EXIT_FAILURE; } for (int i {0}; i < n; ++i) { if (name[i] == monthname) { //Found the monthname! cout << name[i] << " (month number " << i+1 << ") has " << length[i] << " days.\n"; return EXIT_SUCCESS; } } cerr << "Sorry, couldn't find month '" << monthname << "'.\n"; return EXIT_FAILURE; }