#include #include #include using namespace std; int main () { cout << "Please input an integer in the range of 1 to 3999 inclusive: "; int number {}; cin >> number; if (!cin) { cerr << "Sorry, unable to input the integer\n"; return EXIT_FAILURE; } if (number < 1 || number >= 4000) { cerr << "Sorry, " << number << " is out of range.\n"; return EXIT_FAILURE; } const string thousands[] {"", "M", "MM", "MMM"}; const string hundreds[] {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; const string tens[] {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; const string ones[] {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}; int thou {number / 1000}; int hun {(number % 1000) / 100}; int ten {(number % 100) / 10}; int one {number % 10}; cout << thousands[thou] << hundreds[hun] << tens[ten] << ones[one] << "\n"; return EXIT_SUCCESS; }