#include #include #include // for string #include // for getting the current year using namespace std; int main() { string animal[] { "monkey", // 0 "rooster", // 1 "dog", // 2 "pig", // 3 "rat", // 4 "ox", // 5 "tiger", // 6 "hare", // 7 "dragon", // 8 "snake", // 9 "horse", // 10 "sheep" // 11 }; int n {size(animal)}; // the number of elements in the array // Get the current year time_t t {time(nullptr)}; tm *p {localtime(&t)}; int currentYear {p->tm_year + 1900}; cout << "Please type a year: "; int year {0}; cin >> year; if (!cin) { cerr << "Sorry, that wasn't a number.\n"; return EXIT_FAILURE; } if (year <= 0) { cerr << "Sorry, the year has to be a positive number.\n"; return EXIT_FAILURE; } // Determine the correct tense if (year < currentYear) { cout << year << " was the year of the " << animal[year % n] << ".\n"; } else if (year == currentYear) { cout << year << " is the year of the " << animal[year % n] << ".\n"; } else { cout << year << " will be the year of the " << animal[year % n] << ".\n"; } return EXIT_SUCCESS; }