#include #include #include //for class string #include //for the functions time and localtime using namespace std; int main() { const string a[][7] { //number of rows, number of columns {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, //English {"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"}, //Spanish {"Dimoanche", "Lundi", "Mardi", "Mecredi", "Jeudi", "Vendredi", "Samedi"}, //French {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"} //German }; const size_t n {size(a)}; //the number of languages cout << "Choose your language:\n" << "\t0 for English\n" //"\t" is the tab character << "\t1 for Spanish\n" << "\t2 for French\n" << "\t3 for German\n"; int language {0}; cin >> language; if (!cin) { cerr << "Sorry, coild not input an integer.\n"; return EXIT_FAILURE; } if (language < 0 || language >= n) { cerr << "Sorry, language must be in the range 0 to " << n-1 << " inclusive.\n"; return EXIT_FAILURE; } const time_t t {time(nullptr)}; const tm *const p {localtime(&t)}; const int weekday {p->tm_wday}; //in 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 << a[language][weekday] << "\n"; //2 subscripts, each in its own [] return EXIT_SUCCESS; }