#include #include #include //for string using namespace std; //For example, 2024 = 12 * 168 + 8 //Therefore the value of the expression 2024 % 12 is 8 (the year of the dragon). //And since n is 12, the value of the expression 2024 % n is also 8. 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 {sizeof animal / sizeof animal[0]}; //number of elements in array { 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; } cout << year << " was the year of the " << animal[year % n] << ".\n"; if ( year == 2024) { cout << year << "is the year of the " << animal [year % n] << ".\n"; return EXIT_SUCCESS; } else if ( year > 2024){ cout << year << "will be the year of the " << animal [year % n] << ".\n"; return EXIT_SUCCESS; } }