#include #include #include #include using namespace std; int main() { struct language { string name; string weekdays[7]; }; language languages[] { {"English", {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}}, {"Spanish", {"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"}}, {"French", {"Dimoanche", "Lundi", "Mardi", "Mecredi", "Jeudi", "Vendredi", "Samedi"}}, {"German", {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}} }; int n {size(languages)}; //the number of languages cout << "Choose your language:\n"; for (int i {0}; i < n; ++i) { cout << "\t" << i << " for " << languages[i].name << "\n"; } int lang {0}; cin >> lang; if (lang < 0 || lang >= n) { cerr << "Sorry, bad language " << lang << " must be in range 0 to " << n-1 << " inclusive.\n"; return EXIT_FAILURE; } time_t t {time(nullptr)}; tm *p {localtime(&t)}; int weekday {p->tm_wday}; //in the range 0 to 6 inclusive; 0 is Sunday if (weekday < 0 || weekday >= 6) { cerr << "bad weekday " << weekday << " must be in range 0 to 6 inclusive.\n"; return EXIT_FAILURE; } cout << languages[lang].weekdays[weekday] << "\n"; return EXIT_SUCCESS; }