Roman Numeral Converter
Write a program that displays the roman numeral equivalent of any decimal number
between 1 and 20 that the user enters. The roman numerals should be stored in an array of
strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows
the user to continue entering numbers until an end sentinel of 0 is entered.
Input validation: Do not accept scores less than 0 or greater than 20.
std::string generateRoman(int n)
{
//For you to write
}
int main()
{
std::string romans[21];
for(int i(1); i < 21; ++i)
romans[i] = generateRoman(i);
int x;
std::cout << "Enter number in [0, 20]: ";
while(std::cin >> x) {
if(x < 0 || x > 20) {
std::cout << "Invalid number! Enter number in [0, 20]: ";
continue;
}
if (x == 0)
break;
std::cout << x << " in roman is: " << romans[x] << std::endl;
}
}